React Native ios在Mac M1上构建失败



我创建了React项目版本0.66.1。它在Android上运行良好,但在ios上运行不佳。

** BUILD FAILED **以下构建命令失败:CompileC/用户/nunggu/图书馆/开发/Xcode/DerivedData/The_Shop_App-cbmtjvbjevexvvefqivkzkbmmaxa/构建/Intermediates.noindex/Pods.build Debug-iphonesimulator/RCT-Folly.build Objects-normal/arm64/SysUio。o/Users/nunggu/Documents/React Udemy/The_Shop_App/ios/Pods/rgt - folly/The_Shop_App/portability/SysUio.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler(在目标' rgt - folly '从项目'Pods')失败(1)

##################################{"name"the_shop_app"version"0.0.1"private"没错,"scripts" {android";react-native run-android"ios";react-native run-ios"start";"test"jest";;;;},"dependencies" {"react"17.0.2"react-native"0.66.1"},"devDependencies" {"@babel/core":"^ 7.12.9","@babel/runtime":"^ 7.12.5","@react-native-community/eslint-config":"^ 2.0.0","babel-jest"^ 26.6.3","eslint"7.14.0"jest"^ 26.6.3","metro-react-native-babel-preset"^ 0.66.2","react-test-renderer"17.0.2"},"jest" {"preset"react-native"}}

经过多次尝试,我已经找到了解决方案。只需将代码添加到ios文件夹中的Podfile中,如下所示:

use_flipper!({ 'Flipper-Folly' => '2.6.0', 'Flipper' => '0.112.0', 'Flipper-RSocket' => '1.4.0' })
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
flipper_post_install(installer)
find_and_replace("Pods/Headers/Private/RCT-Folly/folly/synchronization/DistributedMutex-inl.h",
"atomic_notify_one(state)", "folly::atomic_notify_one(state)")
find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
"atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
end
end

Flipper兼容版本作为链接:https://cocoapods.org/pods/Flipper。