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

Expo-Go运行正常但TestFlight出现RCTFatal+668崩溃问题求助

问题描述
  • Expo Go模拟器/真机运行正常,但通过EAS构建提交TestFlight后,点击按钮就崩溃,报错RCTFatal+668和-[RCTExceptionsManager reportFatal:stack:exceptionId:extraDataAsJSON:]
  • 代码中添加AsyncStorage.clear()后,Expo Go运行时终端出现AsyncStorage和RCTAsyncLocalStorage相关日志
  • 推测问题可能与stack navigator有关
  • 项目package.json内容:
{
  "name": "{not here for privacy reasons}",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "postinstall": "patch-package"
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "~1.17.3",
    "@react-native-picker/picker": "^2.4.2",
    "@react-navigation/bottom-tabs": "^6.4.0",
    "@react-navigation/native": "^6.0.13",
    "@react-navigation/native-stack": "^6.9.1",
    "deprecated-react-native-prop-types": "^2.3.0",
    "eas": "^0.1.0",
    "expo": "~46.0.16",
    "expo-status-bar": "~1.4.0",
    "patch-package": "^6.4.7",
    "react": "18.0.0",
    "react-native": "0.69.6",
    "react-native-flat-button": "^1.0.6",
    "react-native-safe-area-context": "4.3.1",
    "react-native-screens": "~3.15.0",
    "react-native-swipeable": "^0.6.0",
    "react-native-swipeout": "^2.3.6",
    "skyward-rest": "^1.0.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true
}
问题分析与解决方案

两个问题的关联性

二者存在直接关联:Expo Go是托管沙箱环境,会自动兼容原生模块的部分异常;但EAS构建的是原生独立包,@react-native-async-storage/async-storage在独立构建中可能存在初始化或调用异常。按钮点击逻辑大概率依赖AsyncStorage操作(比如读写后触发导航),当AsyncStorage抛出未捕获异常时,就会触发RCTFatal崩溃。Expo Go中的日志已经提前暴露了AsyncStorage的潜在问题,只是沙箱环境做了容错处理未崩溃。

解决TestFlight崩溃的具体步骤

1. 规范AsyncStorage的调用

  • 所有AsyncStorage异步操作必须用try/catch包裹,避免未捕获异常:
try {
  await AsyncStorage.clear();
  // 后续导航或业务逻辑
} catch (error) {
  console.error('AsyncStorage操作失败:', error);
}
  • 避免在组件挂载前(比如useEffect外部)调用AsyncStorage,独立构建中模块初始化顺序与Expo Go不同,可能导致调用时模块未就绪。

2. 排查Stack Navigator的问题

  • 检查导航跳转时传递的参数,禁止传递无法序列化的数据(比如函数、循环引用对象),TestFlight原生环境对参数序列化要求更严格,Expo Go可能做了宽松处理。
  • 确保NavigationContainer包裹所有导航组件,且不要在AsyncStorage操作未完成时提前触发导航。

3. 升级AsyncStorage依赖版本

Expo 46对应的@react-native-async-storage/async-storage@~1.17.3存在独立构建的兼容bug,建议升级到Expo 46支持的最新兼容版本:

npm install @react-native-async-storage/async-storage@~1.17.11

同时移除patch-package对该模块的自定义补丁,测试是否还会崩溃。

4. 获取完整崩溃日志

  • 在TestFlight中查看应用的完整崩溃报告,定位具体崩溃代码行;
  • 用Xcode连接真机,运行EAS构建的包,直接查看控制台的错误输出,日志比TestFlight的简化版本更详细。

5. 排查第三方依赖兼容性

react-native-swipeout、react-native-swipeable等老旧第三方库可能在React Native 0.69.6的独立构建中存在兼容问题,建议暂时移除这些库测试,逐步定位问题依赖。

内容的提问来源于stack exchange,提问作者BBQ

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 21:35:19