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
相关产品推荐
相关产品推荐

