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

React Native Ignite iOS构建失败:Command PhaseScriptExecution错误

iOS构建失败(EXConstants脚本错误 + 部署目标警告)解决方案

1. 统一所有Pods的iOS部署目标

日志里明确提示react-native-safe-area-context的部署目标为11.0,而Xcode 15.1最低支持12.0,这会引发依赖编译异常:

  • 打开项目ios/Podfile,在文件末尾添加以下代码:
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end
  • 执行命令清理并重新安装Pods:
cd ios
pod deintegrate
pod install

2. 修复EXConstants的脚本构建错误

核心失败原因是[CP-User] Generate app.config for prebuilt Constants.manifest脚本执行异常,按以下步骤处理:

  • 打开Xcode,找到左侧导航栏的Pods项目,展开后选中EXConstants目标,切换到Build Phases标签。
  • 找到[CP-User] Generate app.config for prebuilt Constants.manifest这个Run Script阶段:
    • 取消勾选Based on dependency analysis选项,强制脚本每次构建都运行(对应日志中的警告提示)。
    • 检查脚本内容,确认它能正确定位到项目根目录的app.config.js或app.json文件,路径错误的话手动修正。
  • 确认项目根目录存在app.config.js/app.json,且文件格式正确、无语法错误。

3. 彻底清理构建缓存

缓存问题常导致莫名其妙的构建失败,执行以下操作:

  • Xcode中执行Cmd+Shift+K清理Build Folder,或者通过菜单Product > Clean Build Folder操作。
  • 删除Xcode派生数据:
rm -rf ~/Library/Developer/Xcode/DerivedData
  • 清理Node依赖与缓存:
rm -rf node_modules
yarn cache clean
yarn install
  • 重新安装iOS依赖:
cd ios && pod install

4. 确保Node环境在Xcode中可访问

Xcode构建时可能找不到Node路径,导致脚本执行失败:

  • 打开Xcode项目目标的Build Settings,搜索Shell Path,设置为你当前使用的Shell(比如/bin/zsh)。
  • 可以在EXConstants的Run Script开头添加一行,指定Node路径:
export NODE_PATH=$(which node)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 21:17:37