You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native iOS Expo TestFlight构建启动崩溃问题求助

React Native iOS Expo TestFlight构建启动崩溃(依赖问题排查)

崩溃日志详情

日期/时间: 2024-04-10 17:48:16.6785 +1000
启动时间: 2024-04-10 17:48:16.1961 +1000
系统版本: iPhone OS 17.5 (21F5048f)
发布类型: Beta
基带版本: 2.60.00
报告版本: 104

异常类型: EXC_CRASH (SIGABRT)
异常代码: 0x0000000000000000, 0x0000000000000000
终止原因: SIGNAL 6 中止陷阱: 6
终止进程: LocalFoxGetJobDone [2919]
触发线程: 5

Last Exception Backtrace:
0   CoreFoundation                  0x18f43bf24 __exceptionPreprocess + 164 (NSException.m:249)
1   libobjc.A.dylib                 0x1872de018 objc_exception_throw + 60 (objc-exception.mm:356)
2   LocalFoxGetJobDone              0x100c97c08 RCTFatal + 568 (RCTAssert.m:147)
3   LocalFoxGetJobDone              0x100d095d0 -[RCTExceptionsManager reportFatal:stack:exceptionId:extraDataAsJSON:] + 488 (RCTExceptionsManager.mm:82)
4   LocalFoxGetJobDone              0x100d09de0 -[RCTExceptionsManager reportException:] + 1304 (RCTExceptionsManager.mm:154)
5   CoreFoundation                  0x18f3d8854 __invoking___ + 148
6   CoreFoundation                  0x18f3d78a0 -[NSInvocation invoke] + 428 (NSForwarding.m:3411)
7   CoreFoundation                  0x18f44e1dc -[NSInvocation invokeWithTarget:] + 64 (NSForwarding.m:3508)
8   LocalFoxGetJobDone              0x100cc9548 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 388 (RCTModuleMethod.mm:584)
9   LocalFoxGetJobDone              0x100ccb64c facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&, int, (anonymous namespace)::SchedulingContext) + 456 (RCTNativeModule.mm:196)
10  LocalFoxGetJobDone              0x100ccb29c facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const + 68 (RCTNativeModule.mm:113)
11  LocalFoxGetJobDone              0x100ccb29c invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) + 112 (RCTNativeModule.mm:104)
12  libdispatch.dylib               0x1972c513c _dispatch_call_block_and_release + 32 (init.c:1530)
13  libdispatch.dylib               0x1972c6dd4 _dispatch_client_callout + 20 (object.m:576)
14  libdispatch.dylib               0x1972ce400 _dispatch_lane_serial_drain + 748 (queue.c:3900)
15  libdispatch.dylib               0x1972cef30 _dispatch_lane_invoke + 380 (queue.c:3991)
16  libdispatch.dylib               0x1972d9cb4 _dispatch_root_queue_drain_deferred_wlh + 288 (queue.c:6998)
17  libdispatch.dylib               0x1972d9528 _dispatch_workloop_worker_thread + 404 (queue.c:6592)
18  libsystem_pthread.dylib         0x1ec7de934 _pthread_wqthread + 288 (pthread.c:2696)
19  libsystem_pthread.dylib         0x1ec7db0cc start_wqthread + 8

...(其余线程回溯、二进制镜像内容保留原格式与术语)
EOF

项目package.json依赖

{
  "dependencies": {
    "@react-native-async-storage/async-storage": "1.21.0",
    "@react-native-masked-view/masked-view": "0.3.0",
    "@react-navigation/bottom-tabs": "^6.5.20",
    "@react-navigation/native": "^6.1.17",
    "@react-navigation/native-stack": "^6.9.26",
    "@react-navigation/stack": "^6.3.29",
    "axios": "^1.6.2",
    "expo": "^50.0.0-preview.10",
    "expo-status-bar": "~1.11.1",
    "formik": "^2.4.5",
    "metro": "0.80.4",
    "metro-config": "0.80.4",
    "metro-resolver": "0.80.4",
    "moment": "^2.29.4",
    "react": "18.2.0",
    "react-native": "0.73.6",
    "react-native-device-info": "^10.12.0",
    "react-native-gesture-handler": "~2.14.0",
    "react-native-heroicons": "^4.0.0",
    "react-native-image-picker": "^7.0.3",
    "react-native-reanimated": "~3.6.2",
    "react-native-safe-area-context": "4.8.2",
    "react-native-screens": "~3.29.0",
    "react-native-splash-screen": "^3.3.0",
    "react-native-svg": "14.1.0",
    "react-native-vector-icons": "^10.0.3",
    "react-redux": "^8.1.3",
    "reactotron-react-native": "^5.0.3",
    "redux": "^4.2.1",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.4.2",
    "styled-components": "^6.1.1",
    "yup": "^1.4.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/eslint-config": "^0.72.2",
    "@react-native/metro-config": "^0.72.11",
    "@tsconfig/react-native": "^3.0.0",
    "@types/react": "^18.0.24",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.2.1",
    "eslint": "^8.19.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.76.8",
    "prettier": "^2.4.1",
    "react-test-renderer": "18.2.0",
    "typescript": "^5.3.0"
  }
}

依赖问题排查与解决方案

1. 移除手动安装的Metro依赖

React Native 0.73.6和Expo 50会自带适配的Metro版本,手动安装的metro、metro-config、metro-resolver(0.80.4)会引发版本冲突,导致启动崩溃。执行以下命令移除:

npm uninstall metro metro-config metro-resolver
# 或使用yarn
yarn remove metro metro-config metro-resolver

2. 替换Expo不兼容的第三方库

  • react-native-splash-screen:Expo官方提供expo-splash-screen,社区版在Expo环境下易出现初始化冲突。替换步骤:

    npm uninstall react-native-splash-screen
    npm install expo-splash-screen
    

    随后在app.json中配置splash字段,并在代码中调用expo-splash-screen的API控制启动屏隐藏时机。

  • react-native-image-picker:替换为Expo官方的expo-image-picker,社区版在TestFlight构建中易出现权限或初始化问题:

    npm uninstall react-native-image-picker
    npm install expo-image-picker
    

    在app.json的ios.infoPlist中添加权限描述:

    "ios": {
      "infoPlist": {
        "NSCameraUsageDescription": "需要访问相机以拍摄照片",
        "NSPhotoLibraryUsageDescription": "需要访问相册以选择照片"
      }
    }
    

3. 降级Expo到稳定版

当前使用的expo ^50.0.0-preview.10是预览版本,存在未修复的兼容性问题,建议降级到Expo 49稳定版:

npm install expo@49.0.22
npx expo install --fix

4. 检查并更新第三方库兼容性

  • react-native-device-info:升级到最新兼容React Native 0.73.6的版本:
    npm install react-native-device-info@latest
    
  • 导航库版本统一:升级@react-navigation系列库到相互兼容的最新版本:
    npm install @react-navigation/bottom-tabs@latest @react-navigation/native@latest @react-navigation/native-stack@latest @react-navigation/stack@latest
    

5. 清理缓存并重新构建

执行以下命令清理缓存,避免旧构建文件干扰:

npx expo prebuild --clean
npm cache clean --force
rm -rf node_modules package-lock.json
npm install
npx eas build --platform ios --profile preview

内容的提问来源于stack exchange,提问作者Sai Nitish Bimari

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 22:54:49