在 M1 Macbook 上反应原生运行 iOS 的构建错误

Posted

技术标签:

【中文标题】在 M1 Macbook 上反应原生运行 iOS 的构建错误【英文标题】:Build error of react native run iOS on M1 Macbook 【发布时间】:2021-06-11 04:48:39 【问题描述】:

我第一次在我的 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 的吗?我该如何解决这个问题?

【问题讨论】:

查看react native project not build on MacBook M1 【参考方案1】:

我在 macbook M1 上遵循了这些步骤(cocoapoda 和构建问题):

1- 将终端与 Rosetta 一起使用(确保所有终端都已关闭): 去 Finder --> Applications --> Utilities --> Terminal (然后右键单击 Get Info - 检查 Open using Rosetta) 现在您可以从终端打开终端并安装 Cocoapoda

2- 将 Xcode 与 Rosetta 一起使用(确保 Xcode 已关闭): 去 Finder --> 应用程序 --> Xcode (然后右键单击 Get Info - 检查 Open using Rosetta) 现在 Xcode/simulator 将像 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

【讨论】:

【参考方案2】:

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

快速步骤:

- 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

【讨论】:

以上是关于在 M1 Macbook 上反应原生运行 iOS 的构建错误的主要内容,如果未能解决你的问题,请参考以下文章

对任何崩溃或错误 iOS 做出反应原生白屏

让TensorFlow在Macbook M1上性能翻倍

老外为了在MacBook上玩原神,让M1支持了所有iOS应用 | Github每周精彩分享第一期

Xampp 无法在 m1 Macbook pro 上运行,给我一个错误:

Macbook m1 Big Sur 安装Valet 运行yii2

注册期间未在 Macbook Pro 2020 M1 上检测到适用于 iOS 的 Apple Configurator