Expo iOS预览构建Xcode编译失败:如何调试folly Coroutine.h缺失问题?
iOS EAS构建报错:'folly/experimental/coro/Coroutine.h' 文件找不到 调试方案
问题重现
- 执行命令:
eas build --platform ios --profile preview - 核心报错:
- 'folly/experimental/coro/Coroutine.h' file not found
Refer to "Xcode Logs" below for additional, more detailed logs.
/Users/expo/workingdir/build/ios/Pods/Headers/Public/RCT-Folly/folly/Optional.h:667:10:
fatal error: 'folly/experimental/coro/Coroutine.h' file not found
667 | #include <folly/experimental/coro/Coroutine.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.
调试排查步骤
- 验证依赖版本兼容性:检查项目中React Native版本与RCT-Folly(React Native内置的folly封装)版本是否匹配,头文件缺失通常源于版本不兼容。
- 本地构建排查:执行
eas build --platform ios --profile preview --local将构建拉到本地运行,便于查看完整Xcode日志,定位触发问题的具体依赖。 - 清理Pod缓存:在项目根目录执行
cd ios && pod deintegrate && pod cache clean --all && pod install,清除损坏或过时的Pod缓存后重新安装依赖。
Podfile及协程配置的位置
- Podfile:位于项目根目录的
ios文件夹中(文件名无后缀)。若为Expo Managed Workflow项目,需先执行npx expo prebuild生成原生文件夹。 - 协程配置:无需独立配置文件,直接在Podfile中通过修改RCT-Folly的依赖声明或
post_install钩子调整编译参数即可。
核心修复方案(基于社区讨论)
该问题源于部分RCT-Folly版本中协程相关头文件被移除/迁移,可通过以下步骤解决:
- 锁定RCT-Folly版本:在Podfile中添加指定版本的RCT-Folly依赖(版本需匹配你的React Native版本,示例为2022.05.16.00):
pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec', :modular_headers => true, :version => '2022.05.16.00'
- 禁用协程编译标志:在Podfile末尾添加
post_install脚本,强制关闭folly的协程编译选项:
post_install do |installer| installer.pods_project.targets.each do |target| if target.name == 'RCT-Folly' target.build_configurations.each do |config| config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)'] config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'FOLLY_NO_COROUTINES=1' end end end end
- 重新构建:完成修改后执行
cd ios && pod install,再重新运行eas build命令。
内容的提问来源于stack exchange,提问作者keisler-au
相关产品推荐
相关产品推荐

