React Native 命令PhaseScriptExecution失败,退出代码为非零- Xcode 15.0

i86rm4rw  于 2023-10-22  发布在  React
关注(0)|答案(1)|浏览(198)

我使用的是M2 MacBook Air芯片和xCode。在模拟器中执行应用程序时,我收到以下React Native错误:
以下生成命令失败:PhaseScriptExecution [CP-User]\ Generate\ Specs /User.../FBReactNativeSpec.build/Script-46EB2E110.sh(在项目“Pods”的目标“FBReactNativeSpec”中)(1次失败)
即使我启动一个全新的React Native项目并尝试在iOS上执行,这个问题仍然存在。是什么导致了错误,如何修复?
谢谢你
更新:下面是我对react-native info的配置设置:
info正在获取系统和库信息...

System:
    OS: macOS 14.1
    CPU: (8) arm64 Apple M2
    Memory: 498.81 MB / 24.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.8.1 - /usr/local/bin/npm
    Watchman: 2023.09.25.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.13.0 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2022.2 AI-222.4459.24.2221.10121639
    Xcode: 15.0/15A240d - /usr/bin/xcodebuild
  Languages:
    Java: 19.0.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.66.4 => 0.66.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

完成程序:
1.产品目的地选择显示Rosetta
1.链接器标志添加-ld64

mnemlml8

mnemlml81#

将此代码添加到post_install中的Pod文件中,然后再次安装Pod

installer.pods_project.targets.each do |target|
       target.build_configurations.each do |config|
         config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
       end
     end

例如我的podfile

post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    installer.pods_project.targets.each do |target|
           target.build_configurations.each do |config|
             config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
           end
         end
  end
end

相关问题