React Native项目在iOS真机运行的时候报错Command PhaseScriptExecution failed with a nonzero exit code

当开发完 React Native 项目,想在 iOS 真机上运行,结果获得了 Command PhaseScriptExecution failed with a nonzero exit code 错误。
image.png

以上错误在模拟器上是没有的,在网上找解决方案,大概都是修改 Pods-项目名-frameworks 在 Xcode 项目中 Pods -> Targets Support Files -> Pods-项目名 -> Pods-项目名-frameworks 中 (大约在第 44 行) 将

source="$(readlink "${source}")"

替换为

source="$(readlink -f "${source}")"

当你打开文件之后,你发现已经加了-f,看来这个解决方案太旧了,已经不适合当下(2024.8)了
image.png

下面给出有效的解决方案:

  1. 找到 build,选择"Errors Only",如下图所示
    image.png
    可以看到错误是在 Run custom shell script 'Bundle React Native code and images' 时产生
  2. 在 xcode 中找到 Build Phases 找到 Bundle React Native code and images,勾选 For install builds only
    image.png
    再次编译将不会有问题。

如果还遇到问题,请升级 cocoapods


已发布

分类

作者:

标签

评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注