【问题标题】:PhaseScriptExecution error in React Native appReact Native 应用程序中的 PhaseScriptExecution 错误
【发布时间】:2021-06-12 02:31:57
【问题描述】:

创建项目后运行 react-native run-ios 时遇到此错误

错误 -

error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening BoltAssignment.xcworkspace.
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace BoltAssignment.xcworkspace -configuration Debug -scheme BoltAssignment -destination id=3E598855-6D4F-4F36-BEE1-8663A1F71787


nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local"
Run `unset PREFIX` to unset it.
nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local"
Run `unset PREFIX` to unset it.
Command PhaseScriptExecution failed with a nonzero exit code

warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'Flipper-Glog' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.4, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'Flipper-PeerTalk' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'libwebp' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'YogaKit' from project 'Pods')
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the BoltAssignment editor. (in target 'BoltAssignment' from project 'BoltAssignment')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'Flipper-DoubleConversion' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'boost-for-react-native' from project 'Pods')
warning: no rule to process file '/Users/harsh_nagalla/dev/BoltAssignment/ios/Pods/Flipper-RSocket/rsocket/README.md' of type 'net.daringfireball.markdown' for architecture 'x86_64' (in target 'Flipper-RSocket' from project 'Pods')
warning: no rule to process file '/Users/harsh_nagalla/dev/BoltAssignment/ios/Pods/Flipper-RSocket/rsocket/benchmarks/CMakeLists.txt' of type 'text' for architecture 'x86_64' (in target 'Flipper-RSocket' from project 'Pods')
warning: no rule to process file '/Users/harsh_nagalla/dev/BoltAssignment/ios/Pods/Flipper-RSocket/rsocket/benchmarks/README.md' of type 'net.daringfireball.markdown' for architecture 'x86_64' (in target 'Flipper-RSocket' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'RNFastImage' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'SDWebImageWebPCoder' from project 'Pods')

** BUILD FAILED **


The following build commands failed:
    PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/harsh_nagalla/Library/Developer/Xcode/DerivedData/BoltAssignment-cxeqsscopunscndrzxcrfnugkasb/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-1F0D93C9412E4439D9C46216EB143B15.sh
(1 failure)

后续步骤-

  1. 纱线安装
  2. 启动 Metro 服务器
  3. cd ios -> pod 安装
  4. npx react-native run-ios

对本机反应很新,所以我完全不知道为什么会发生这种情况。如果有人可以提供帮助,我们将不胜感激。

如果你也遇到了同样的问题,但仍然像我一样一无所知,那么请分享并投票,以便尽可能多的人看到它。

【问题讨论】:

  • 有同样的问题。令人惊讶的是,它在我的另一台 Mac 上运行良好。我检查了 pod、node、yarn 版本,它们都是一样的。使用 Xcode 打开 /ios/ 文件夹中的 .xcworkspace 文件并从中构建对我来说很好。
  • @SergioDiez 是的,我也遇到了同样的情况,非常奇怪
  • 升级到 0.64.0 后遇到完全相同的问题。
  • 我也遇到了同样的问题,这似乎是一个 nvm 问题,当我打开 xcode 时,应用程序构建良好。
  • 我在构建应用程序时遇到了问题,我意识到我在使用yarn ios 时使用了npx react-native run-ios 应用程序构建成功。

标签: ios xcode react-native


【解决方案1】:

我想出了一个解决方案,如果您使用的是 nvm,请确保您没有其他全局安装的 Node/npm 版本

如果你不确定你是否有一个全球版本,去你的 bash_profile/zshrc 并注释三个nvm初始化行(export NVM_DIR="$HOME/.nvm" [...]),然后打开一个新终端并执行node --version,如果它仍然可以找到某些东西,则意味着您在某个地方有一个全局版本,您可以通过which node 找到它的路径。

就我而言,我使用的是 Homebrew,并且我有一个全局版本的 Node,我什至不知道它来自 yarn 公式,我在运行 brew uses --installed node 后发现了它。我继续使用brew uninstall --force yarn 卸载了yarn,它自动卸载了它的node/npm 依赖项,然后取消注释nvm 初始化行,然后我使用nvm 的npm 和npm i -g yarn 重新安装了yarn,现在一切正常。

【讨论】:

  • 哇,不知道你是怎么想出来的,但经过数周的头痛和可怕的解决方法后,这解决了它。谢谢!
  • 我的.zshrc 中有unset PREFIX。您的解决方案 + 删除该行为我做了(几个月后使用解决方法从 XCode 启动 RN 项目)
【解决方案2】:

目前唯一对我有用的解决方案(RN v0.64.0),直到正确确定此问题的根本原因(尽管似乎与 nvm 有关!)是转到您的 /node_modules/react-native/scripts/find-node.sh 并将这两行设置在顶部。

您可以使用patch-package 来永久保留这些更改。

unset npm_config_prefix
unset PREFIX

【讨论】:

    【解决方案3】:

    我遇到了同样的错误,我刚刚运行了错误中建议的命令:

    $ 未设置 PREFIX。

    之后应用程序正常构建。

    【讨论】:

    • 嗨 Cata,这为我指明了正确的方向。它不仅仅在未设置的情况下运行,而是在我删除旧的 ~/.nvm 文件夹时运行(我以前使用过 nvm)。现在它按预期工作。谢谢!
    • @SergioDiez 也应该是一个答案。帮我解决了问题。
    • @SergioDiez - 这也为我解决了问题!
    【解决方案4】:

    在 Mac 上,使用这两个步骤,我解决了问题。

    1. 我已删除旧的 ~/.nvm 文件夹。 from-comment
    2. 然后我通过命令ln -s $(which node) /usr/local/bin/node(from-answer)创建了

    【讨论】:

      【解决方案5】:

      遇到同样的错误。尝试了很多修复,但没有任何帮助。 我通过在我的 Mac 上创建新用户解决了这个问题。 IOS 应用程序开始在 Xcode 中再次构建。我会做更多的研究是什么原因。我猜是因为开发环境设置不好。

      【讨论】:

        【解决方案6】:

        如果您明确知道要运行的节点版本,有一种方法可以在没有补丁包的情况下注入它(或者,我遇到的一个兔子洞,sed)。 find-node.sh 脚本实际上只是更新了要查找节点的 PATH,generate-specs.sh 实际上是在查找节点二进制文件...但它允许您使用 NODE_BINARY 环境变量覆盖它。

        所以你可以NODE_BINARY=/usr/local/bin/mynode npx react-native run-ios

        【讨论】:

          【解决方案7】:

          我遇到了同样的问题,最快的工作方式(由于一些专业问题)是完全删除 NVM 并通过 brew (macOS) 安装 Node

          【讨论】:

            【解决方案8】:

            React Native 0.64 使用新的 codegen 部分,当项目路径中有空格时,这不能正常工作(还)。这是一个know bug,将在未来的版本中解决,PR already is made

            现在你可以使用没有空格的路径。

            作品

            /home/wbroek/projectname/
            

            不工作

            /home/wbroek/project name/
            

            【讨论】:

            • 但是,在原记者的错误信息中,空格似乎根本没有问题。可能有空格问题,但我不明白你的答案与发帖人的问题有何关系?还是我错过了什么?我可以!
            • 是的,我的路径没有任何空间,我仍然得到这个错误,我认为 Harsh 不是我们在日志中看到的。
            【解决方案9】:

            这有点小技巧,但在你的 podfile 中试试这个: Ref

            post_install do |installer|
            installer.pods_project.targets.each do |target|
              if (target.name&.eql?('FBReactNativeSpec'))
                target.build_phases.each do |build_phase|
                  if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
                    target.build_phases.move(build_phase, 0)
                  end
                end
              end
            end
            

            【讨论】:

              【解决方案10】:

              我也遇到过类似的问题。我在 react native github repo 上找到了解决方案。

              删除

              export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion from ~/.bash_profile .
              

              注释掉project/node_modules/react-native/scripts/find-node.sh中的所有代码 帮助解决了这个问题。

              您也可以查看原文 https://github.com/facebook/react-native/issues/31249#issuecomment-811715288

              【讨论】:

                【解决方案11】:

                我遇到了同样的问题,可以按照以下步骤解决。

                1. {你的项目} > ios > Podfile

                在“hermes_enabled”设置中从“false”更改为“true”。

                :hermes_enabled => true
                
                1. cd ios && pod 安装

                2. npx react-native run-ios

                【讨论】:

                • hermes 是可选的,应用应该在没有它的情况下构建
                【解决方案12】:

                我使用npx react-native run-ios 而不是yarn ios 解决了这个问题。

                也许可以帮助你。

                【讨论】:

                • 老实说,yarn ios 在后台运行相同的命令。我试过了还是不行。
                • 打开你的 package.json 并检查脚本。
                【解决方案13】:

                是的,有同样的问题,没有意识到这是一个新的 RN 版本。已降级到 0.63.4 并且可以正常工作:

                yarn 升级 react-native@0.63

                【讨论】:

                • 降级并不是真正的解决方案
                猜你喜欢
                • 2021-06-18
                • 1970-01-01
                • 2016-11-15
                • 1970-01-01
                • 2021-11-13
                • 2021-08-30
                • 2020-11-15
                • 2020-06-01
                相关资源
                最近更新 更多