源码

支持Xcode10和适配iPhone XS Max、iPhone XR

1.png

目前我们项目已做了Xcode10(swift4.0)和新机型的适配,总结一下遇到的问题和修改的内容,希望帮助到其他人,如果您有不同的看法或遗漏,欢迎指出!

1.第三方库编译报错

如果项目里用到了Mixpanel-swift和SwiftLint,这两个在Xcode10上会报错,目前作者已提交新版本分别是2.4.5和0.27.0,更新后即可解决报错。

2.library not found for - lstdc++.6.0.9

pod工程编译通过后会进行主工程的编译,如果依赖了libstdc++.tbd和libstdc++.6.0.9.tbd,就会报这个error,原因是苹果在XCode10和iOS12中移除了libstdc++这个库,由libc++这个库取而代之,苹果的解释是libstdc++已经标记为废弃有5年了,建议大家使用经过了llvm优化过并且全面支持C++11的libc++库。

临时的解决方法就是把libstdc++.6.0.9.tbd这个文件导入到Xcode10中,分别放到以下目录 /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/  这时编译可以通过。

但这只是临时的解决方案,如果你自己的业务模块使用了libstdc++,那么就把模块代码重新调整为依赖libc++,然后重新检查是否存在问题,重新编译。如果你引用的第三方厂商提供的sdk中依赖了libstdc++,那么抓紧联系厂商,要求版本升级。

3.Enum case '...' not found in type '...'

解决好上面两个报错,编译程序时还会显示这个error,具体场景如下:

PosVisitQuestionType: String {
    case text
    case textArea = "text_area"
    case dropDownList = "drop_down_list"
    case radioButton = "radio_button"
}
let type: PosVisitQuestionType!
...
switch type {
case .text, .textArea:
    errorText = NSLocalizedString("Please enter the following options", comment: "")
case .dropDownList, .radioButton:
    errorText = NSLocalizedString("Click the right button to get current location", comment: "")
default:
    break
}

Xcode10建议每个case 情况下加“?”

(0)

本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/zhichixcode10heshipeiiphone-xs-maxiphone-xr.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 30, 2018 at 01:26 上午

热评文章

发表回复

[必填]

我是人?

提交后请等待三秒以免造成未提交成功和重复