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

React Native iOS构建报错:PhaseScriptExecution [CP-User] Generate Specs

解决React Native iOS PhaseScriptExecution [CP-User] Generate Specs构建错误

核心问题定位

Xcode构建时硬编码了旧的Node路径(/opt/homebrew/Cellar/node/19.0.1/bin/node),即便更换Node版本和安装方式,构建脚本仍在调用这个不存在的路径。

具体解决步骤

1. 修正CocoaPods的Node路径配置

  • 打开项目ios/Podfile,在文件开头添加以下代码,指定当前nvm管理的Node路径:
    node_path = `which node`.strip
    ENV['NODE_BINARY'] = node_path
    
  • 保存后,在ios目录下执行:
    pod deintegrate && pod install
    

2. 重置Xcode构建缓存与配置

  • 清理派生数据:打开Xcode,点击菜单栏Xcode > Settings > Locations,找到Derived Data,点击箭头打开文件夹,删除当前项目的所有派生数据。
  • 清除Xcode缓存:关闭Xcode后执行
    rm -rf ~/Library/Caches/com.apple.dt.Xcode
    
  • 重启Xcode,重新打开项目尝试构建。

3. 同步终端与Xcode的环境变量

  • 检查终端的Node路径:
    echo $PATH && which node
    
  • 配置Xcode环境:打开Product > Scheme > Edit Scheme,选择Build阶段,勾选Use custom working directory并填入项目根目录;在Environment Variables中添加PATH,值为终端中echo $PATH的输出结果。

4. 验证Yarn与Node的关联

  • 检查Yarn使用的Node版本:
    yarn node --version
    
  • 若版本不符,重新关联Yarn到当前nvm的Node:
    nvm use 16.13.2
    npm install -g yarn
    
  • 验证结果:
    which yarn && yarn node --version
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 11:20:38