【问题标题】:Swift Module stability: Module compiled with Swift X.Y cannot be imported by the Swift X.Z compilerSwift 模块稳定性:使用 Swift X.Y 编译的模块不能被 Swift X.Z 编译器导入
【发布时间】:2021-01-04 10:31:31
【问题描述】:

让我们从现有的问题开始,

Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler

Module compiled with Swift 5.1 cannot be imported by the Swift 5.0 compiler

Module compiled with Swift 5.1.2 cannot be imported by the Swift 5.2.4 compiler

而且,现在使用 XCode 12(12A7209)

使用 Swift 5.2.4 编译的模块不能被 Swift 5.3 导入 编译器

框架是在较低版本的 Swift (Swift 5.2.4) 中编译的。但是,它与 XCode 12 beta 完美配合。

已尝试的解决方案:

重点是二进制框架的Swift ABI稳定性以及如何在不同的swift版本中实现它。

请指教。提前谢谢!

【问题讨论】:

  • 预建框架的.swiftmodule文件夹是否包含.swiftinterface文件?
  • @Eugene Dudnyk 是的。

标签: ios swift xcode frameworks xcode12


【解决方案1】:

您需要模块稳定性,而不是 ABI 稳定性。

Module Stability的区别和实现方式,在此描述:https://www.donnywals.com/what-is-module-stability-in-swift-and-why-should-you-care/

这里是WWDC session,它解释了 swift 二进制框架(时间码:17:00)。

简而言之,你的框架

  • 应该使用Build Libraries for Distribution 设置为Yes 构建
  • Skip Install 属性设置为No
  • .xcframework 的形式分发,带有模拟器和设备的变体

您需要确保嵌入到.xcframework 中的框架都在Modules/<name>.swiftmodule 文件夹中包含.swiftinterface 文件。

【讨论】:

  • 感谢您的回复。让我试试解决方案。
猜你喜欢
  • 2022-01-07
  • 2019-09-08
  • 2020-02-27
  • 1970-01-01
  • 1970-01-01
  • 2021-09-26
  • 2019-02-23
  • 2020-02-19
  • 1970-01-01
相关资源
最近更新 更多