Xcode12项目适配

Overview

最近更新Xcode12,发现编译有的项目的时候会出现些问题,然后一个个解决所有项目完美编译通过。

最近看有的群里在讨论Xcode12编译项目的一些问题,觉得可以整理一篇自己遇到问题的文章,便于遇到同样问题的朋友查阅。

编译

项目无法在模拟器中运行

将项目运行到模拟器的时候报No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=arm64 armv7)错误。

修复:

TARGETS->Build Settings->搜索VALID_ARCHS, 然后添加模拟器的指令集。如果有多个TARGETS时,需要分别添加。

如图所示:
项目运行模拟器适配

Library not found for -lstdc++.6.0.9

果然自己保存在github中的lstdc++库是对的,忘记从哪个版本Xcode去除了lstdc++库,每次更新Xcode的时候都需要重新添加一下。

修复:

  • github中下载lstdc++,将其复制到下面的路径下即可。
1
2
3
4

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/

代码

Swift代码中报Constructing an object of class type 'Self' with a metatype value must use a 'required' initializer。错误

修复:

1
2
3
required init() {
super.init(
}