在 M1 Macbook 上 React Native 运行 iOS 的构建错误

时间:2021-03-13 10:12:47

标签: swift xcode react-native apple-m1

我第一次在 M1 Silicon Apple 计算机上使用“react-native init ReactNStudy”初始化了新的 react-native 项目。

地铁建设者没有任何问题。

在构建步骤时,我收到了很多日志错误。像这样开始部分错误:

info Found Xcode workspace "ReactNCalisma.xcworkspace" info Launching iPhone 12 (iOS 14.4) info Building (using "xcodebuild -workspace ReactNCalisma.xcworkspace -configuration Debug -scheme ReactNCalisma
-destination id=E914C899-172A-45AE-AFB6-BEBA505887E1") (node:25639) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency (Use `node --trace-warnings ...` to show where the warning was created) error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening ReactNCalisma.xcworkspace. Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace ReactNCalisma.xcworkspace -configuration Debug -scheme ReactNCalisma -destination id=E914C899-172A-45AE-AFB6-BEBA505887E1

并像这样结束部分错误:

objc[25723]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1fc2be7a0) and ?? (0x1189b42b8). One of the two will be used. Which one is undefined.
objc[25723]: Class AMSupportURLSession is implemented in both ?? (0x1fc2be7f0) and ?? (0x1189b4308). One of the two will be used. Which one is undefined.
** BUILD FAILED **


The following build commands failed:
    Ld /Users/USERNAME/Library/Developer/Xcode/DerivedData/ReactNCalisma-anxlznepgpgzoyfpokskqpwmffzt/Build/Products/Debug-iphonesimulator/ReactNCalisma.app/ReactNCalisma normal
(1 failure)

info Run CLI with --verbose flag for more details.

之后我尝试使用“xcodebuild”运行:

<块引用>

cd ios && xcodebuild

但在这部分我得到错误:

fatal error: module map file
      '/Users/USERNAME/Desktop/Projects/ReactNCalisma/ios/build/Release-iphoneos/YogaKit/YogaKit.modulemap'
      not found

** BUILD FAILED **
The following build commands failed:
    CompileC /Users/USERNAME/Desktop/Projects/ReactNCalisma/ios/build/ReactNCalisma.build/Release-iphoneos/ReactNCalisma.build/Objects-normal/arm64/ReactNCalisma_vers.o /Users/USERNAME/Desktop/Projects/ReactNCalisma/ios/build/ReactNCalisma.build/Release-iphoneos/ReactNCalisma.build/DerivedSources/ReactNCalisma_vers.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler
    CompileC /Users/USERNAME/Desktop/Projects/ReactNCalisma/ios/build/ReactNCalisma.build/Release-iphoneos/ReactNCalisma.build/Objects-normal/armv7/ReactNCalisma_vers.o /Users/USERNAME/Desktop/Projects/ReactNCalisma/ios/build/ReactNCalisma.build/Release-iphoneos/ReactNCalisma.build/DerivedSources/ReactNCalisma_vers.c normal armv7 c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)

我尝试通过删除 Pod 并重新安装来解决,我检查了我的 Xcode 终端设置,但无法解决此问题。

这个问题是关于 M1 的吗?我该如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

我在 macbook M1 上按照这些步骤操作(cocoapoda 和构建的问题):

1- 在 Rosetta 中使用终端(确保所有终端都已关闭): 转到 Finder --> Applications --> Utilities --> Terminal(然后右键单击获取信息 - 选中使用 Rosetta 打开) 现在您可以打开终端并从终端安装 Cocoapoda

2- 将 Xcode 与 Rosetta 结合使用(确保 Xcode 已关闭): Go Finder --> Application --> Xcode(然后右键单击“获取信息”-选中“使用 Rosetta 打开”) 现在 Xcode/模拟器将像 Rosetta 一样工作

3- 在 Podfile(在 ios 文件夹中)中注释此部分

# use_flipper!
# post_install do |installer|
#   flipper_post_install(installer)
# end

然后重新安装pod:

cd ios/
$ rm -rf build/
$ pod install

观看此视频:

https://youtu.be/UrxM1SyAXAE

答案 1 :(得分:0)

我之前也遇到过同样的问题。但是,现在我可以成功编译和构建 react native run-ios。 我已经恢复并创建了关于如何使用 M1 芯片运行 React Native iOS Macbook 的指南文章。

enter image description here

快速步骤:

- set terminal to use Rosetta
- set XCode to use Rosetta
- small adjust on podFile if you have problem with react native flipper.

完整指南如下:https://handi.dev/blog/how-run-react-native-on-macbook-m1-apple-silicon