【问题标题】:React Native crashes on react-native run-iosReact Native 在 react-native run-ios 上崩溃
【发布时间】:2019-06-01 14:25:11
【问题描述】:

我遇到了一个问题,即我的 react 本机应用程序打开然后立即关闭。我运行 react-native run-ios,Metro Bundler 加载到 100%,然后应用程序崩溃。我到处搜索,找不到问题所在!

我在模拟器系统日志中发现了这个:

Jan  6 20:01:44 Mac-mini MyApp[31448]: assertion failed: 18C54 16B91: libxpc.dylib + 79599 [F7D4B188-D5C2-3E5E-BB76-BC7C6A368166]: 0x7d
Jan  6 20:01:46 Mac-mini com.apple.CoreSimulator.SimDevice.9ABCA7C0-8781-4151-B5C7-ED03FE429BC1[26939] (UIKitApplication:com.myApp.app[0xaf59][26962][31448]): Service exited due to SIGSEGV | sent by exc handler[31448]

虽然构建成功,但我可以看到以下内容,这会导致问题吗?

The following commands produced analyzer issues:
Analyze /Users/maxy/Desktop/myApp/node_modules/react-native/React/Base/RCTModuleMethod.mm normal x86_64
Analyze /Users/maxy/Desktop/myApp/node_modules/react-native/Libraries/Network/RCTNetInfo.m normal x86_64

(2 个带有分析器问题的命令)

我已尝试删除 iOS/build 文件。从 Xcode 清理项目和构建。调试和发布版本。

当我从 Xcode 运行时,它会在输出中显示以下内容:

2019-01-06 20:08:57.083678+0000 myApp[31468:269858]  - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2019-01-06 20:08:57.198519+0000 myApp[31468:269858] 5.15.0 - [Firebase/Analytics][I-ACS023007] Analytics v.50400000 started
2019-01-06 20:08:57.200271+0000 myApp[31468:269858] 5.15.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2019-01-06 20:08:57.225194+0000 myApp[31468:269858] 5.15.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
2019-01-06 20:08:57.252 [info][tid:main][RCTCxxBridge.mm:216] Initializing <RCTCxxBridge: 0x600002578ff0> (parent: <RCTBridge: 0x600003168620>, executor: (null))
2019-01-06 20:08:57.254831+0000 myApp[31468:269808] Initializing <RCTCxxBridge: 0x600002578ff0> (parent: <RCTBridge: 0x600003168620>, executor: (null))
2019-01-06 20:08:57.447 [info][tid:main][RCTRootView.m:293] Running application myApp ({
initialProps =     {
};
rootTag = 1;
})
2019-01-06 20:08:57.447252+0000 myApp[31468:269808] Running application myApp ({
initialProps =     {
};
rootTag = 1;
})
2019-01-06 20:08:57.480500+0000 myApp[31468:269808] -[RNFirebaseMessaging init] [Line 34] Setting up RNFirebaseMessaging instance
2019-01-06 20:08:57.480835+0000 myApp[31468:269808] -[RNFirebaseAuth init]_block_invoke [Line 42] RNFirebaseAuth:instance-created
2019-01-06 20:08:57.480973+0000 myApp[31468:269808] -[RNFirebaseAuth init] [Line 45] RNFirebaseAuth:instance-initialized
2019-01-06 20:08:57.481224+0000 myApp[31468:269808] -[RNFirebase init] [Line 12] Setting up RNFirebase instance
2019-01-06 20:08:57.481635+0000 myApp[31468:269808] -[RNFirebaseNotifications init] [Line 45] Setting up RNFirebaseNotifications instance
2019-01-06 20:08:57.496791+0000 myApp[31468:269808] -[RNFirebaseMessaging messaging:didReceiveRegistrationToken:] [Line 87] Received new FCM token: fXHq98QGnyw:APA91bH7b66ywMfcEVB6yPSUG_p1pkFugA4PY1EtmkJaG_43JtNkPnAG-MPJ6cP2RsknEWwGqUqzfIhOCfocWM_NSQfAQVhTY1JRTwenzn-tczYhUK90d4P7nynu1xAD81kur39mVG2E
2019-01-06 20:08:57.528077+0000 myApp[31468:269869] [] nw_socket_handle_socket_event [C5.1:1] Socket SO_ERROR [61: Connection refused]
2019-01-06 20:08:57.547389+0000 myApp[31468:269869] [] nw_socket_handle_socket_event [C5.2:1] Socket SO_ERROR [61: Connection refused]
2019-01-06 20:08:57.549096+0000 myApp[31468:269887] [] nw_connection_get_connected_socket [C5] Client called nw_connection_get_connected_socket on unconnected nw_connection
2019-01-06 20:08:57.626521+0000 myApp[31468:269877] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x7fc74e606a40] get output frames failed, state 8196
2019-01-06 20:08:57.626723+0000 myApp[31468:269877] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x7fc74e606a40] get output frames failed, state 8196
2019-01-06 20:08:57.627564+0000 myApp[31468:269877] TIC Read Status [1:0x0]: 1:57
2019-01-06 20:08:57.627978+0000 myApp[31468:269877] TIC Read Status [1:0x0]: 1:57

还有什么我可以检查的/还有更多日志吗? 当我做 react-native run-android 时,一切都没有问题。

提前谢谢你。

【问题讨论】:

  • 检查您的所有console.log 语句,因为有时记录大对象可能会导致崩溃。
  • 感谢您的评论。我评论了我所有的 console.log 语句,但仍然没有运气。

标签: react-native


【解决方案1】:

1:如果您安装了pod,请确保检查所有库。安装的外部库可能存在问题。 并确保运行pod install 并删除node_modules 文件夹,然后再次运行npm install(也关闭打包程序)

2:您还可以使用sentry 或任何其他崩溃报告库来检测崩溃,它会为您提供准确的行号。(确保安装 react-native 版本)。

3: 有时崩溃报告库无法工作,原因可能是在加载js bundle 之前发生崩溃,因此该库尚未初始化并且无法检测到崩溃。如果是这样,您可以安装本机崩溃报告库,您可以为此使用fabric,甚至可以使用bugsnag

4:即使这3个步骤都不起作用,有时由于证书的一些问题,应用程序在启动时可能会崩溃,有时应用程序可以工作几天然后突然崩溃,如果出现这种情况。确保您的证书生成正确。

这些是发生这种崩溃的少数情况。通常是第一个

【讨论】:

  • 感谢您提供的信息。我认为 no.1 是正确的,因为我以前从未安装过 pod 等或使用 xcode 做过任何事情,我多次运行了一些更新并链接了不同的库,在重新阅读一些文档后我认为这是错误的。我目前正在从头开始并单独添加每个包并进行测试以确保。完成后我会更新你。再次感谢。
  • 乐于助人。 :) 如果有什么问题请告诉我,你也可以一个一个地安装一个库,也可以一个一个地测试,这样你就可以很容易地看出是哪个库造成了一些问题。
  • 刚刚将您的答案标记为正确。我重新安装了所有东西,现在它按预期工作。谢谢!
猜你喜欢
  • 1970-01-01
  • 2022-01-11
  • 2017-09-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-30
  • 2019-07-30
相关资源
最近更新 更多