React Native IOS生成版本:RCTFatalException崩溃和SocketProtocolError YellowBox

时间:2016-05-03 01:56:03

标签: javascript ios xcode react-native

我有一个本机反应应用程序(目前仅限iOS) - 来自JS背景并且不熟悉XCode,我发现有关为iOS创建生产版本的文档非常稀疏。根据{{​​3}}上的一个模糊句子:

The JS bundle will be built for dev or prod depending on your app's scheme (Debug = development build with warnings, Release = minified prod build with perf optimizations). To change the scheme navigate to Product > Scheme > Edit Scheme... in xcode and change Build Configuration between Debug and Release.

然而,在XCode v7.3中,这是我在单击Product>时看到的内容。方案>编辑方案(没有选项"更改调试和发布之间的构建配置"):

https://facebook.github.io/react-native/docs/running-on-device-ios.html

我了解如何在本地手机上运行,​​以及在模拟器和手机上运行之间的区别。它可以在模拟器和插入的手机上正常工作。

现在,当我存档应用程序时,保存以进行临时分发,上传到TestFairy,在手机上下载,然后运行它 - 我经常看到像Yellowbox警告的内容:

Product > Scheme > Edit Scheme

同样可疑的崩溃事件(由TestFairy记录):

Application Specific Information:
*** Terminating app due to uncaught exception 'RCTFatalException: Could not connect to development server.

Ensure the following:
- Node server is running and available on the same network - run 'npm start' from react-native root
- Node server URL is correctly set in AppDelegate

URL: http://192.168.0.21:8081/index.ios.bundle?platform=ios', reason: 'Could not connect to development server.

Ensure the following:
- Node serv...'

Last Exception Backtrace:
0   CoreFoundation                      0x22939b8b __exceptionPreprocess (in CoreFoundation) + 127
1   libobjc.A.dylib                     0x220f6dff objc_exception_throw (in libobjc.A.dylib) + 39
2   CoreFoundation                      0x22939ad1 -[NSException initWithCoder:] (in CoreFoundation) + 1
3   myapp                            0x000b1ad5 0x98000 + 105173
4   myapp                            0x000cb01f 0x98000 + 208927
5   myapp                            0x000c9149 0x98000 + 201033
6   libdispatch.dylib                   0x224cbcbf _dispatch_call_block_and_release (in libdispatch.dylib) + 11
7   libdispatch.dylib                   0x224cbcab _dispatch_client_callout (in libdispatch.dylib) + 23
8   libdispatch.dylib                   0x224d0559 _dispatch_main_queue_callback_4CF (in libdispatch.dylib) + 1533
9   CoreFoundation                      0x228fb7d5 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ (in CoreFoundation) + 9
10  CoreFoundation                      0x228f9ccf __CFRunLoopRun (in CoreFoundation) + 1591
11  CoreFoundation                      0x22848289 CFRunLoopRunSpecific (in CoreFoundation) + 517
12  CoreFoundation                      0x2284807d CFRunLoopRunInMode (in CoreFoundation) + 109
13  GraphicsServices                    0x23e64af9 GSEventRunModal (in GraphicsServices) + 161
14  UIKit                               0x26f732c5 UIApplicationMain (in UIKit) + 145
15  myapp                            0x0009d4e7 0x98000 + 21735
16  libdyld.dylib                       0x224f4873 start (in libdyld.dylib) + 3

那么,在XCode中创建用于分发的反应本机生成版本的正确步骤是什么?

2 个答案:

答案 0 :(得分:2)

<强>更新

我找到了对这个问题How to build .IPA for React Native?提出的回答,以解决问题。由于该帖子上的问题与我的问题无关,因此我将通过使用命令行解决创建生成构建的问题:

react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios

并且还在AppDelegate.m中取消注释这一行:

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

答案 1 :(得分:0)

FWIW,我用react-native 0.39.2遇到了这个问题。

要解决它:

1)为主项目的'Other Linker Flags'添加'Objc -lc ++'。

2)使用react-native项目的根目录(index.ios.js所在的位置)创建main.jsbundle: react-native bundle --platform ios --dev false --entry-file index.ios.js --bundle-output iOS / main.jsbundle

3)在XCode中打开项目,在导航器中选择项目,然后选择目标,然后选择Build Phases,然后复制Bundle Resources,并将main.jsbundle添加到项目中,以便将其复制到生成的应用程序中。 / p>

然后,该应用程序将在我的iPad上启动。

在这一点上,文档可能会有所改善。

希望这有帮助。

-Ken