【问题标题】:PhaseScriptExecution failed for react-native-config on XCode buildXCode 构建中 react-native-config 的 PhaseScriptExecution 失败
【发布时间】:2021-03-16 22:20:38
【问题描述】:

我正在尝试在 Xcode 上构建我的 React Native 项目,但它失败了。构建目标是 react-native-config 错误:运行自定义 shell 脚本 '[CP-User] Config codegen' "Command PhaseScriptExecution failed with a nonzero exit code"。

尝试使用 --verbose 运行它,我得到以下信息:

以下构建命令失败:PhaseScriptExecution [CP-User]\ Config\ codegen /User/userName/Library/Developer/Xcode/DerivedData/projectName/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react- native-config-build/Script-21BEEA33BD6A21BF27B73D38DC1AD4.sh

我正在使用 React-Native-Config 1.4.1 运行 React Native 0.63.1,我尝试重新安装 node_modules、pod、删除 DerivedData 并清理构建,但没有运气。我也没有在 Build Phases > Run Script 下看到任何对 react-native-config 的引用。

有什么办法解决这个问题吗?

【问题讨论】:

    标签: ios xcode react-native cocoapods react-native-config


    【解决方案1】:

    这通常是由格式错误的.env 文件引起的。仔细检查您的.env

    【讨论】:

    • 我在我的 .env 文件 (# with three words) 中有一条评论,当我删除它时,我克服了这个错误?‍♂️
    • 这个 .env 文件在哪里?
    • 项目的根目录。
    • 我的项目中没有 env 文件。 ://
    • 由于某种原因,我前段时间将评论从 # the comment 切换为 ; the comment,但将其切换回 # 已修复!
    【解决方案2】:

    我有同样的问题,我按照教程来构建 ios,它在教程中已经很老了(一年)我添加了一些代码,其中包括一些类似的东西

    post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == 'React'
      target.remove_from_project
      end
      if target.name == 'react-native-config'
        phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
        phase.shell_script = 'cd ../../'\
        '&& RNC_ROOT=./node_modules/react-native-config/'\
        '&& export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig'\
        '&& export BUILD_DIR=$RNC_ROOT/ios/ReactNativeConfig'\
        '&& ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby'
        target.build_phases << phase
        target.build_phases.move(phase,0)
      end
     end
    end
    

    请从 podfile 中删除它并按照 react-native-config 的文档使用环境变量here 删除后不要忘记安装 pod

    在构建时注意构建方案(您在构建时使用哪个)

    【讨论】:

    • 我的 Podfile 中没有此代码,但按照您链接到的这些说明解决了问题:github.com/luggit/…
    【解决方案3】:

    通常当依赖没有更新时会出现这个问题。

    您可以尝试以下步骤:

    1-) cd ios
    2-) rm -rf Podfile.lock
    3-) rm -rf Pods
    4-) delete .xcworkspace
    5-) pod install
    

    【讨论】:

      猜你喜欢
      • 2019-12-13
      • 2015-06-01
      • 2016-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-07
      • 1970-01-01
      相关资源
      最近更新 更多