美文网首页ios实用技术
Xcode Legacy Build system废弃,以及适配

Xcode Legacy Build system废弃,以及适配

作者: Trigger_o | 来源:发表于2022-06-22 11:55 被阅读0次

环境:
M1芯片
New Build System
simulator

报错内容:
模拟器运行会报错,真机运行正常
Build input file cannot be found: '…/Library/Develop/Xcode/DerivedData/.../Debug-iphonesimulator/XXX.app/XXX' (in target 'XXX' from project 'XXX')

或者还有这种报错:
找不到某个pods库的头文件,比如AFNetworking.h, module xxx等

或者报错:
找不到Swift-OC桥接文件 xxx.h

或者还有关于arm64的报错都可以尝试

原因:
1.从Xcode12开始,Build-setting -> UserDefined中的VALID ARCHS被删除(可以自己加回来但没必要),更换为Build-setting -> architectures中的Excluded Architectures.
2.New Build System将被废弃

更新
3.在之前的mac上,arm64被自动转换为x86_64,但是在m1上arm64是有效的架构,于是不会转换为x86_64,但是很多库并没有支持arm64,于是就出现这些报错.

如何解决:
1.设置主项目的Excluded Architectures, target和project都有这项设置,可以都设置上

image.png

2.设置pod项目的Excluded Architectures,在podfile中添加

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

如果有其他设置,在" installer.pods_project.build_configurations.each do |config|"下面增加EXCLUDED_ARCHS这行就行.
接下来执行pod install,
完成之后可以看到pod下的project和target全部都设置了Excluded Architectures

3.如果你的Build-setting -> UserDefined中还有VALID ARCHS,那么应该删除,选中,点左边的减号.

最后clean ,清空/Library/Develop/Xcode/DerivedData文件夹, 再重新编译.

如果仍然不能解决:
首先考虑更新cocoapods: arch -x86_64 pod update (在M1上需要执行这个命令,其他的正常pod update)
然后还不行可能要考虑重装cocoapods

另外RN项目可能有其他的设置需要注意,至少得更新一下.

排除了arm64之后,控制台会报警告
Warning: Error creating LLDB target at path '/Users/trigger/Library/Developer/Xcode/DerivedData/XXX-aezbsmdulhwyqxbynkcbeetgpngt/Build/Products/Debug-iphonesimulator/XXX.app'- using an empty LLDB target which can cause slow memory reads from remote devices.

使用Rosetta打开
据说也可以解决上面的问题,我没有测试.
不过我用这个方法解决了模拟器卡顿的问题,模拟器完全不能滑动,只能一下一下的跳,甚至滑动手势都不能识别.开启使用Rosetta打开就正常了.
duck栏右键simulator,选项->在Finder中显示->右键显示简介->勾选

image.png

同理Xcode也可以勾选,界面会更流畅,刷新率更高,缺点还没搞清,可能相当于m1白买了(狗头

相关文章

网友评论

    本文标题:Xcode Legacy Build system废弃,以及适配

    本文链接:https://www.haomeiwen.com/subject/idzyvrtx.html