简介
上周在打包上传后,报了一个警告,大致的意思就是这样的:2019年3月必须使用Xcode 10.1或更高版本
,此时的我还在用 Xcode 9,刚好最近刚上了包,就升级了Xcode 10
开始采坑
1、升级完成后直接报了libray not found for -lstdc++.6.0.9
,在 Xcode 10 Release Notes 中有着如下的描述
Building with libstdc++ was deprecated with Xcode 8 and is not supported in Xcode 10 when targeting iOS. C++ projects must now migrate to libc++ and are recommended to set a deployment target of macOS 10.9 or later, or iOS 7 or later. Besides changing the C++ Standard Library build setting, developers should audit hard-coded linker flags and target dependencies to remove references to libstdc++ (including -lstdc++, -lstdc++.6.0.9, libstdc++.6.0.9.tbd, and libstdc++.6.0.9.dylib). Project dependencies such as static archives that were built against libstdc++ will also need to be rebuilt against libc++. (40885260)
所以苹果在 Xcode10 中移除了对 libstdc++ 的支持。
2、具体的报错可能会有这些
- libray not found for -lstdc++.6.0.9
- libray not found for -lstdc++
- libray not found for libstdc++.6.0.9.tbd
3、解决办法
- 在Build Phases -> Link Binary With Libraries 中删除
lstdc++
、lstdc++.6.0.9
、libstdc++.6.0.9.tbd
,并且添加libc++
。 - 对于有使用 pod 的项目,在debug.xcconfig和release.xcconfig中也需要删除
lstdc++.6.0.9
、
4、删除完了这些后还可能编译不成功的问题
我在做完这些操作后,我 clean 了项目,然后再次编译的时候,还是有报错,但是其实我已经把引用到这个库的地方都删掉了
我全局搜索了一下,在Build Settings 中找到了这个
接着就是在c++ standard Library 中选择 libc++ ,然后编译,成功解决了报错。
升级后关于Xs Max 和 XR的适配
花了一下午的时间升级了Xcode 10,接着就是关于iPhone Xs Max 和XR 的适配了
启动页的分辨率
Xs Max: 1242 * 2688
XR: 828*1792.png
一些判断用的宏
#define isPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
#define iPhone5 ([UIScreen mainScreen].bounds.size.height == 568)
#define iPhone4 ([UIScreen mainScreen].bounds.size.height == 480)
#define iPhone6 ([UIScreen mainScreen].bounds.size.height == 667)
#define iPhone6P ([UIScreen mainScreen].bounds.size.height == 736)
#define iPhoneX ([UIScreen mainScreen].bounds.size.height == 812)
#define iPhoneXR ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
#define iPhoneXsMax ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size)&& !isPad : NO)
脱坑
终于完成了 Xcode 9 到 Xcode 10 的迁移,总的来说比之前可能稍微麻烦了一些。在此做个记录