from: https://www.jianshu.com/p/87a5cca2a490

 

新版本的M1芯片运行模拟器报CocoaPods库(如:WechatOpenSDK报arm64错误)错误,是因为M1兼容问题,解决办法有两种如下:强烈推荐方法2

方法1:强制打开xcode对x86的支持,有缺点:因为还是采用x86,编译速度很慢。

关闭xcode--应用程序--xocde--右键简介--通用--勾选使用Rosetta打开--重启xcode即可
 
image.png

方法2(推荐):完全采用ARM架构,编译速度显著提升。

1、Build Settings--选择basic--在User-Defined下点击 ”+“
2、输入 ”EXLUDED_ARCHS“--debug和release选择Any iOs Simulator SDK,输入arm64
3、Build Settings下找到EXcluded Architectures 设置debug和release选择Any iOs Simulator SDK,输入arm64
4、Podfile 加入下面的代码
post_install do |installer|
    installer.pods_project.build_configurations.each do |config|
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
end
5、重新pod install
6、最后点击xcode的Buildtime(如下面的截图)自动适配代码即可。注:如果没出现就再跑一遍pod install。

注意:遇到这种情况:ld: Framework not found),需要多clear下项目的缓存,关闭然后重启xcode即可。
 
image.png
#source 'https://github.com/CocoaPods/Specs.git'
# 指明依赖库的来源地址
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
inhibit_all_warnings!
platform :ios, '9.0'
target "XXX" do

pod 'xxx'
end

post_install do |installer|
    installer.pods_project.build_configurations.each do |config|
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
end


作者:啾啾啾_YB
链接:https://www.jianshu.com/p/87a5cca2a490
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
posted on 2023-04-21 10:44  是谁啊?  阅读(231)  评论(0编辑  收藏  举报