使用Swift 4.1.2编译的模块无法在Swift 4.1.50中导入:Xcode 10 Error [英] Module compiled with Swift 4.1.2 cannot be imported in Swift 4.1.50: Xcode 10 Error
问题描述
Swift 4.2出来了,当我使用 ObjectMapper
以及其他一些pod时,我在项目中收到此错误消息:
使用Swift 4.1.2编译的模块无法在Swift 4.1.50中导入
那么如何告诉Xcode开始更新我的项目并将其迁移到Swift 4.2?
在 Swift 4.2中/ strong>根据
ObjectMapper GitHub repo上有一些拉取请求修复了这个问题,但它们是正在使用 complier指令功能将在新的Xcode测试版中发布。
Swift 4.2 came out and I'm receiving this error message in my project when using ObjectMapper
and some other pods too:
Module compiled with Swift 4.1.2 cannot be imported in Swift 4.1.50
So how do I tell Xcode to start updating my project and migrate it to Swift 4.2?
In Swift 4.2 there is a change in implementation of Implicitly Unwrapped Optional (IUO), as per the swift blog now implicit unwrapped optional T! will be considered as T? with and extra flag for the compiler to know it is an implicit unwrap optional.
The new mental model for IUOs is one where you consider ! to be a synonym for ? with the addition that it adds a flag on the declaration letting the compiler know that the declared value can be implicitly unwrapped.
Because of this change there might be some source compatibility issue that may requires you to modify your code before it will compile successfully.
In Swift 3, declarations like var a: Int? would result in a having type Optional, and declarations like var b: String! would result in b having type ImplicitlyUnwrappedOptional. It changed in Swift 4.2 hence its showing error for ObjectMapper for Xcode 10 which comes with swift 4.2 and similar implementation was done for 3.* for Xcode 10.
In Objectmapper library there are some declarations of functions which showed warnings earlier for swift 4.1, now showing as error for swift 4.2. Refer the below image for warnings in Xcode 9.4 and swift 4.1
There are some pull requests on the ObjectMapper GitHub repo which has fixed the issue but they are waiting for the new Xcode beta release as per the discussions as it is using complier directive feature which got recently accepted will be released with new Xcode beta.
这篇关于使用Swift 4.1.2编译的模块无法在Swift 4.1.50中导入:Xcode 10 Error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!