building for iOS Simulator, but linking in object file built for iOS, file for architecture arm64

一、问题

app在真机能运行,在模拟器不能正常编译,出现报错

二、原因

字面看是模拟器状态下找不到对应的arm64架构文件,实质是M1芯片的兼容性问题

PS:用M1芯片电脑 很多时候会遇到兼容性问题,当常规方案解决不了问题,试着搜索的时候带上关键字M1或许能更快找到答案

三、过程

网上搜索了很多无非就是需要该配置文件,但是亲测实际只需要2步

四、解决方案具体如下2步:

4.1 、podfile文件末尾添加以下脚本:然后执行pod install 命令。

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

4.2、打开Finder的应用程序-Xcode右键 显示简介 勾选通过Rosetta打开。

然后选模拟器编译通过~

此方法适用于搭载M1芯片的Macbook

参考文章如下,感谢

1https://blog.csdn.net/ws1836300/article/details/108755295

【2】https://www.jianshu.com/p/5a4d85a8ac35

3https://www.jianshu.com/p/0fc2a6402870(这篇文章步骤是相对比较清晰的,但与我最终得到的答案有出入,没能最终解决问题)

【4】https://blog.csdn.net/lvsonghai/article/details/110873689(这篇是解决问题的很关键一点)

你可能感兴趣的:(iOS,issues,ios)