简体   繁体   English

Xcode发行版中的Bundlejs错误(react-native)

[英]Bundlejs error on release build in Xcode (react-native)

For some reason I am getting the following error when building a release version of my application via react-native. 出于某种原因,通过react-native构建应用程序的发行版时,出现以下错误。

*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: t.typeof is not a function. ***由于未捕获的异常'RCTFatalException:未处理的JS异常:t.typeof不是函数,因此终止了应用程序。 (In 't.typeof("function"==typeof Symbol?Symbol.iterator:"@@iterator")', 't.typeof' is undefined) (/Users/../THEAPP.app/main.jsbundle:11)', reason: 'Unhandled JS Exception: t.typeof is not a function. (在't.typeof(“ function” == typeof Symbol?Symbol.iterator:“ @@ iterator”)'中,'t.typeof'未定义)(/ Users /../ THEAPP.app/main.jsbundle: 11)”,原因:“未处理的JS异常:t.typeof不是函数。 (In 't.typeof("function...' (在't.typeof(“ function ...”

This is the source of the code that has the above error that I found in my bundlejs file: 这是在我的bundlejs文件中发现上述错误的代码源:

!(function(e){"use strict";var r,t=e.babelHelpers={};t.typeof="function"==typeof Symbol&&"symbol"===t.typeof("function"==typeof Symbol?Symbol.iterator:"@@iterator")?

I have tried both of these methods of a release build: 我已经尝试了发布构建的这两种方法:

  1. Making bundle by editing the Scheme to be a Release bundle 通过将方案编辑为发布捆绑包来制作捆绑包
  2. Export a bundle myself by using the following: react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios 通过使用以下命令自己导出捆绑软件: react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

I get the same error for both of these. 对于这两个我都得到相同的错误。 And of course, this is after I change my AppDelegate.m to the following: 当然,这是在将AppDelegate.m更改为以下代码之后:

//jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

I also followed someone's response from Github issues and tried the following, but got another separate issue entirely after the fact: 我还跟踪了某人对 Github问题的回答 ,并尝试了以下方法,但事后完全又遇到了另一个问题:

I did: 我做了:

npm uninstall -g babel-preset-env
npm install --save @babel/preset-env

Added this to my package.json file 将此添加到我的package.json文件中

 "babel": { "presets": ["@babel/preset-env", "react-native"] }

And created a .babelrc file in my root project with: 并在我的根项目中创建一个.babelrc文件,其内容如下:

{ "presets": ["@babel/preset-env", "react-native"] }

Then get this on an Xcode build: 然后在Xcode构建上获取此代码:

在此处输入图片说明

Environment 环境

  • OS : macOS High Sierra 10.13.4 操作系统 :macOS High Sierra 10.13.4
  • Node : 9.11.1 节点 :9.11.1
  • npm : 5.6.0 npm :5.6.0
  • Watchman : 4.9.1 值班员 :4.9.1
  • Xcode : Version 9.4 (9F1027a) Xcode :版本9.4(9F1027a)
  • react : 16.3.1 反应 :16.3.1
  • react-native : 0.55.4 反应本机 :0.55.4

我通过完全重启我的应用程序并使用以下方法解决了这个问题:

react-native init PROJECTNAME

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM