M1芯片Mac运行RN

报错信息:

项目场景:

新款M1芯片的Macbook Pro中运行React Native项目,最新版本的。

node v15.x
cocoapods 1.10.x


问题描述:

一开始React Native项目运行正常,后来经过xcode版本降级,降级失败后。又重新升级xcode发现React Native 无法正常运行了。现象是运行就卡住。

在这里插入图片描述

使用xcode运行,在编译阶段报错。

in /Users/ndwl-1/demo/AwesomeProject/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a(cryptlib.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/ndwl-1/demo/AwesomeProject/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a' for architecture arm64

原因分析:

项目代码相同,一开始能运行后来不行了。甚至新建的项目也无法运行起来。所以我分析很有可能是因为xcode的bug导致。或者因为xcode 升级导致什么规则发生变化。

解决方案:

我的猜测:
删除xcode 缓存试试。

在这里插入图片描述

网上查了一下,觉得有价值的文章

《After updating to Xcode 12 I get The linked library ‘libPods-*****.a’ is missing one or more architectures required by this target: arm64. 》

https://github.com/facebook/react-native/issues/29984

在这里插入图片描述

https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built

Steps to resolve the issue :

Solution 1:

Select Project Target
Go to build setting
Select All
search for “Build Active Architecture Only”
Build Active Architecture Only to “Yes” even for release mode.
Build Again
Solution 2:

Select Project Target
Go to build setting
Select All
search for “Excluded Architecture”
Add “arm64” to both Release and Debug mode for the “Any iOS Simulator SDK” option.
Build Again

在这里插入图片描述

It’s not really a proper fix, but what worked for my project is:

following the suggestions provided by: https://realm.io/docs/swift/latest/#cocoapods
Installing cocoapods 1.10.0.rc1
setting the BuildActiveArchitectureOnly to Yes in the cocoapods project
Now when you build your app for your device or you’re archiving make sure to set this back to No, or alternatively, use a different config for this (e.g: I have Debug set to Yes, Release to No).

相关文章

方法: 打开一个新的可跨域的chrome窗口实现方法: 1. 打开终...
MacBook Pro 14价格和配置对比 尺寸 SOC	内存&#...
现在给大家介绍一下如何查询MAC的生产日期,希望对你查询MAC...
1、点击【编辑虚拟机设置】,转到【CD/DVD (SATA)】,选中【...
注意:用哪个版本的 Python 运行安装脚本,pip 就被关联到哪...
Mac 安装nvm