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

React Native全新项目iOS版本启动失败求助

React Native新架构iOS构建失败(PhaseScriptExecution错误)解决办法

针对你遇到的iOS构建脚本执行失败问题,结合你的环境(Mac Ventura 13.5、Xcode 15.0.1、Node 21、RN 0.73.0新架构项目),可以尝试以下步骤解决:

  • 降级Node版本到LTS版
    RN 0.73.0官方推荐使用Node 18.x/20.x LTS版本,Node 21为奇数版本存在兼容性风险。用nvm切换版本:

    nvm install 20
    nvm use 20
    

    切换后重新执行yarn install,再运行yarn pod-install。

  • 修复Xcode 15脚本路径问题
    进入iOS目录打开Podfile,在post_install块中添加Xcode 15适配配置:

    post_install do |installer|
      react_native_post_install(installer)
      __apply_Xcode_12_5_M1_post_install_workaround(installer)
    
      # 适配Xcode 15的脚本路径问题
      installer.pods_project.targets.each do |target|
        if target.name == "React-Codegen"
          target.build_configurations.each do |config|
            config.build_settings["GENERATE_INFOPLIST_FILE"] = "YES"
          end
        end
      end
    end
    

    保存后重新执行yarn pod-install。

  • 彻底清理全链路缓存
    除了DerivedData,还要清理Metro、Pod缓存:

    # 重置Metro缓存
    npx react-native start --reset-cache
    # 清理iOS构建文件与Pods
    cd ios
    rm -rf build/ Pods/ Podfile.lock
    yarn pod-install
    cd ..
    # 删除Xcode DerivedData
    rm -rf ~/Library/Developer/Xcode/DerivedData
    
  • 检查Xcode脚本配置
    打开iOS目录下的.xcworkspace,选中项目target进入Build Phases,找到Bundle React Native code and images脚本:
    确认脚本内容中NODE_BINARY路径正确,示例:

    export NODE_BINARY=$(command -v node)
    ../node_modules/react-native/scripts/react-native-xcode.sh
    

    若路径错误,手动修改为项目根目录的node_modules相对路径。

  • 修复脚本执行权限
    确保RN的Xcode脚本有执行权限:

    chmod +x node_modules/react-native/scripts/react-native-xcode.sh
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 16:27:31