React Native ios 在 Mac M1 上构建失败
我创建了 React 项目版本 0.66.1。它在 Android 上运行良好,但在 ios 上运行不佳。
** 构建失败 ** 以下构建命令失败: CompileC /Users/nunggu/Library/Developer/Xcode/DerivedData/The_Shop_App-cbmtjvbjevexvvefqivkzkbmmaxa/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/arm64/SysUio.o /Users/nunggu/Documents/React\ Udemy/The_Shop_App/ios/Pods/RCT-Folly/folly/portability/SysUio.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler(在项目“Pods”的目标“RCT-Folly”中) (1失败)
##################################### { "name": "the_shop_app", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "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 。