微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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).

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐