M1 Mac react-native iOS 构建错误(在项目 'Pods' 的目标 'RCT-Folly' 中)

M1 Mac react-native iOS build error (in target 'RCT-Folly' from project 'Pods')

在 M1 Mac 上,使用 npm 8.3.1node 17.4,当我 运行 npx react-native run-ios 我收到 2 个错误:

The following build commands failed:
    CompileC /Users/Steven/Library/Developer/Xcode/DerivedData/HelloSteve-hghgfcwemhoaiacfwlophutqqzbh/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/arm64/SysUio.o /Users/Steven/Documents/Projects/React\ Native/HelloSteve/ios/Pods/RCT-Folly/folly/portability/SysUio.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'RCT-Folly' from project 'Pods')
    CompileC /Users/Steven/Library/Developer/Xcode/DerivedData/HelloSteve-hghgfcwemhoaiacfwlophutqqzbh/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/arm64/NetOps.o /Users/Steven/Documents/Projects/React\ Native/HelloSteve/ios/Pods/RCT-Folly/folly/net/NetOps.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'RCT-Folly' from project 'Pods')
(2 failures)

this answer 开始,Podfile 中不存在行 flipper_post_install(installer)

this answer开始,我在Podfile中注释掉了# use_flipper!(),运行pod install然后npx react-native run-ios收到了类似的错误:

The following build commands failed:
        CompileC /Users/Steven/Library/Developer/Xcode/DerivedData/HelloSteve-hghgfcwemhoaiacfwlophutqqzbh/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/arm64/SysUio.o /Users/Steven/Documents/Projects/React\ Native/HelloSteve/ios/Pods/RCT-Folly/folly/portability/SysUio.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'RCT-Folly' from project 'Pods')
(1 failure)

我尝试了 solution here, (commenting out the line typedef uint8_t clockid_t; in Time.h),但也没有用。

感谢帮助。

我 运行 在更新项目目标 OS 版本时遇到了类似的问题。

实际上 Xcode 会要求您为不同的包更改目标 OS 版本,然后导致我找不到 RCT 包。

因此,当 xcode 告诉您有一个很好的选项可以更改不同 pods 的目标设置时,请务必小心。要么一步一步地尝试,要么保持原样,只要它正在构建并且 运行.

npm install 然后 pod install 分别 arch -x86_64 pod install 因为我也在 M1 上 运行。

因为它可能也需要做一些事情,所以我也会在 xcode 中禁用 arm64 你的项目目标构建阶段在构建设置“排除的体系结构”下并且只安装 pods 和 arch -x86_64 pod install.

我遵循了 this link 提供的解决方案,其中:

  • 清理 pod 和 yarn 缓存
  • 然后安装较低版本的react-native: npx react-native@0.64.2 init MyApp

这解决了我的问题。