React-Native iOS发布版Testflight启动闪屏后崩溃求助
旧版React-Native iOS应用Testflight启动崩溃问题分析与解决方向
问题背景
旧版React-Native iOS应用归档上传Testflight流程正常,但启动后仅显示闪屏随即崩溃,Xcode中无法查看Testflight崩溃日志,以下是应用依赖清单及Xcode捕获的日志信息:
应用依赖清单
"appcenter": "2.6.1", "axios": "0.19.2", "babel-eslint": "10.1.0", "bugsnag-react-native": "2.23.6", "contentful": "7.13.1", "date-holidays": "1.4.12", "expo": "36.0.0", "expo-av": "8.0.0", "expo-barcode-scanner": "8.0.0", "expo-camera": "8.0.0", "expo-contacts": "8.0.0", "expo-font": "8.0.0", "expo-local-authentication": "8.0.0", "expo-localization": "8.0.0", "expo-location": "8.0.0", "expo-secure-store": "8.0.0", "google-libphonenumber": "3.2.6", "i18n-js": "3.5.1", "lodash": "4.17.15", "moment": "2.24.0", "prop-types": "15.7.2", "react": "16.9.0", "react-dom": "16.9.0", "react-native": "0.61.4", "react-native-android-open-settings": "1.3.0", "react-native-animatable": "1.3.3", "react-native-awesome-card-io": "0.8.2", "react-native-code-push": "6.1.0", "react-native-fast-image": "7.0.2", "react-native-firebase": "~5.6.0", "react-native-gesture-handler": "1.5.1", "react-native-get-location": "2.2.1", "react-native-get-random-values": "^1.8.0", "react-native-in-app-review": "3.2.2", "react-native-keyboard-aware-scroll-view": "0.9.1", "react-native-maps": "0.26.1", "react-native-qrcode-svg": "6.0.3", "react-native-reanimated": "^1.4.0", "react-native-safe-area-context": "0.7.3", "react-native-screens": "2.0.0-alpha.12", "react-native-splash-screen": "^3.3.0", "react-native-svg": "11.0.1", "react-native-swipeout": "2.3.6", "react-native-unimodules": "0.7.0", "react-native-view-pdf": "0.13.2", "react-native-web": "0.11.7", "react-native-webview": "8.1.2", "react-navigation": "4.1.1", "react-navigation-drawer": "2.3.4", "react-navigation-stack": "2.1.1", "react-navigation-tabs": "2.7.0", "react-redux": "7.2.0", "redux": "4.0.5", "redux-form": "8.3.0", "redux-persist": "6.0.0", "redux-thunk": "2.3.0", "sha1": "1.1.1", "uuid": "3.4.0", "validator": "12.2.0"
Xcode捕获日志
2023-07-14 20:39:38.128415+0200 Bootlegger[37801:3500119] Sent 3 sessions to Bugsnag 2023-07-14 20:39:38.129611+0200 Bootlegger[37801:3500202] [connection] nw_socket_handle_socket_event [C4.1.1:1] Socket SO_ERROR [61: Connection refused] 2023-07-14 20:39:38.134973+0200 Bootlegger[37801:3500202] [connection] nw_socket_handle_socket_event [C4.1.2:1] Socket SO_ERROR [61: Connection refused] 2023-07-14 20:39:38.138497+0200 Bootlegger[37801:3500119] [connection] nw_connection_get_connected_socket_block_invoke [C4] Client called nw_connection_get_connected_socket on unconnected nw_connection 2023-07-14 20:39:38.138727+0200 Bootlegger[37801:3500119] TCP Conn 0x600001879680 Failed : error 0:61 [61] 2023-07-14 20:39:38.350679+0200 Bootlegger[37801:3500125] Connection 6: received failure notification 2023-07-14 20:39:38.350889+0200 Bootlegger[37801:3500125] Connection 6: failed to connect 12:8, reason -1 2023-07-14 20:39:38.351000+0200 Bootlegger[37801:3500125] Connection 6: encountered error(12:8) 2023-07-14 20:39:38.352079+0200 Bootlegger[37801:3500203] Task <D8BD8504-EFD4-48D8-9CB0-6D50D1330A00>.<2> HTTP load failed, 0/0 bytes (error code: -1003 [12:8]) 2023-07-14 20:39:38.353058+0200 Bootlegger[37801:3500202] Task <D8BD8504-EFD4-48D8-9CB0-6D50D1330A00>.<2> finished with error [-1003] Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=8, NSUnderlyingError=0x600002677b10 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], _kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <D8BD8504-EFD4-48D8-9CB0-6D50D1330A00>.<2>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDownloadTask <D8BD8504-EFD4-48D8-9CB0-6D50D1330A00>.<2>" ), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://settings.crashlytics.com/spi/v2/platforms/ios/apps/co.za.wigroup.bootleggers/settings?build_version=4&display_version=3.1&instance=96d9f8a4413b4b766379fe976e5437d5e51b411c&source=1, NSErrorFailingURLKey=https://settings.crashlytics.com/spi/v2/platforms/ios/apps/co.za.wigroup.bootleggers/settings?build_version=4&display_version=3.1&instance=96d9f8a4413b4b766379fe976e5437d5e51b411c&source=1, _kCFStreamErrorDomainKey=12} 2023-07-14 20:39:38.360868+0200 Bootlegger[37801:3500202] [Fabric] failed to download settings Error Domain=FABNetworkError Code=-6 "(null)" UserInfo={retryLimit=1, NSErrorFailingURLStringKey=https://settings.crashlytics.com/spi/v2/platforms/ios/apps/co.za.wigroup.bootleggers/settings?build_version=4&display_version=3.1&instance=96d9f8a4413b4b766379fe976e5437d5e51b411c&source=1} INFO : BSG_KSCrash.m (262): -[BSG_KSCrash sendAllReportsWithCompletion:]: Sending 6 crash reports INFO : BSG_KSCrashReport.c (1557): void bsg_kscrashreport_writeStandardReport(BSG_KSCrash_Context *const, const char *const): Writing crash report to ~/Library/Developer/CoreSimulator/Devices/68A38606-C7DF-4F17-B6E1-866E938E96C6/data/Containers/Data/Application/AC1BDAAB-5968-4FC1-89C3-C1766695F27F/Library/Caches/KSCrashReports/Bootlegger/Bootlegger-CrashReport-3B856092-F97F-4069-A23F-420CBCFAF3E9.json ERROR: BSG_KSMach.c (172): _Bool bsg_ksmachfillState(const thread_t, const thread_state_t, const thread_state_flavor_t, const mach_msg_type_number_t): thread_get_state: (ipc/send) invalid destination port ERROR: BSG_KSCrashReport.c (384): struct __darwin_mcontext64 *bsg_kscrw_i_getMachineContext(const BSG_KSCrash_SentryContext *const, const thread_t, struct __darwin_mcontext64 *const): Failed to fetch machine state for thread 1795 2023-07-14 20:39:40.674279+0200 Bootlegger[37801:3500125] Reports sent. INFO : BSG_KSCrash.m (262): -[BSG_KSCrash sendAllReportsWithCompletion:]: Sending 0 crash reports
崩溃原因分析
从日志中可提取关键信息:
- Crashlytics服务失效:日志显示无法解析
settings.crashlytics.com主机名,HTTP错误码-1003表示找不到指定服务器。Crashlytics已整合到Firebase,原域名已停止服务,而应用使用的react-native-firebase~5.6.0版本未适配域名变更。 - 启动流程中断:应用启动时尝试连接Crashlytics获取配置,因连接失败触发未处理异常,导致启动流程中断,闪屏后崩溃。
- 崩溃日志捕获异常:Bugsnag的KSCrash组件在捕获崩溃现场时出现
thread_get_state错误,无法生成有效崩溃报告,导致Xcode中无完整日志。
解决方向
1. 调整Crashlytics相关依赖
- 若无需Crashlytics,直接移除项目中相关配置和依赖,包括
react-native-firebase内Crashlytics模块的初始化代码。 - 若保留崩溃上报,升级
react-native-firebase到支持Firebase Crashlytics的新版本,替换旧域名配置,确保使用有效服务地址。
2. 处理启动阶段网络异常
在应用启动代码中,为Crashlytics配置请求添加异常捕获逻辑,即使请求失败,也要保证应用能继续启动流程,避免因服务不可用直接崩溃。
3. 修复崩溃日志捕获问题
升级bugsnag-react-native到兼容当前环境的最新版本,解决KSCrash组件的线程状态捕获异常,确保能生成有效崩溃日志。
4. 适配iOS新版本要求
应用使用的React Native 0.61.4和Expo 36.0.0版本较旧,可能不兼容当前iOS系统的安全协议或API要求,考虑升级到稳定兼容版本,修复系统适配问题。
内容的提问来源于stack exchange,提问作者Frederick Jeffrey
相关产品推荐
相关产品推荐

