当开发完 React Native 项目,想在 iOS 真机上运行,结果获得了 Command PhaseScriptExecution failed with a nonzero exit code
错误。
以上错误在模拟器上是没有的,在网上找解决方案,大概都是修改 Pods-项目名-frameworks
在 Xcode 项目中 Pods -> Targets Support Files -> Pods-项目名 -> Pods-项目名-frameworks 中 (大约在第 44 行) 将
source="$(readlink "${source}")"
替换为
source="$(readlink -f "${source}")"
当你打开文件之后,你发现已经加了-f,看来这个解决方案太旧了,已经不适合当下(2024.8)了
下面给出有效的解决方案:
- 找到 build,选择"Errors Only",如下图所示
可以看到错误是在Run custom shell script 'Bundle React Native code and images'
时产生 - 在 xcode 中找到
Build Phases
找到Bundle React Native code and images
,勾选For install builds only
再次编译将不会有问题。
如果还遇到问题,请升级 cocoapods
发表回复