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

Expo iOS Release构建启动崩溃:DevSettings模块未找到问题排查

React Native + Expo托管工作流iOS发布包启动崩溃:DevSettings TurboModule找不到

问题现象

使用React Native结合Expo托管工作流及config plugins开发时,Android发布包(通过npx expo run:android --variant release构建)运行正常,但iOS发布包(通过npx expo run:ios --configuration Release或EAS构建)启动即崩溃,报错如下:

Fatal Exception: RCTFatalException: Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes

所有构建过程均成功,但iOS包无法正常启动。

已尝试的解决方法

  • 手动构建JS bundle:npx react-native bundle --entry-file index.ts --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
  • 在Xcode中修改构建配置为Release模式

解决方案

1. 检查Expo核心配置

打开app.json或app.config.js,确认生产环境配置无误:

  • 确保expo字段下的development属性设置为false
  • 排查iOS专属配置(如bundleIdentifier)无错误,未包含调试相关的自定义项
  • 检查config plugins列表,确认没有插件强制引入开发环境专属的原生模块

2. 清理并重新预构建原生文件

运行命令彻底清理缓存并重新生成iOS原生项目文件:

npx expo prebuild --clean

完成后重新执行iOS发布构建:

npx expo run:ios --configuration Release

3. 排查代码中的开发环境残留

  • 全局搜索DevSettings、__DEV__等关键字,确保生产环境代码中没有调用开发专属API
  • 确认第三方调试依赖(如日志工具、调试库)已通过条件编译排除在生产包外,示例:
if (__DEV__) {
  import('react-native-debugger').then(module => module.setup());
}

4. 验证EAS构建配置(若使用EAS)

检查eas.json中的production配置,确保符合生产环境要求:

{
  "build": {
    "production": {
      "ios": {
        "buildConfiguration": "Release"
      },
      "env": {
        "EXPO_PUBLIC_ENV": "production"
      }
    }
  }
}

确认未开启developmentClient、debug等调试相关选项。

5. 优先使用EAS构建生产包

本地构建易受缓存、Xcode配置残留影响,建议使用EAS构建生产包——它会在干净的云端环境执行构建,更贴合Expo托管工作流的规范,避免本地环境不一致导致的问题。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 14:15:11