Search code examples
iosswiftxcodeframeworksxcode12

Swift Module stability: Module compiled with Swift X.Y cannot be imported by the Swift X.Z compiler


Let's start by existing questions,

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

And, now with XCode 12(12A7209)

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

The framework was compiled in the lower version of Swift (Swift 5.2.4). However, it worked perfectly with XCode 12 beta.

Solution tried:

Whole point is the Swift ABI stability for binary framework and how to achieve it across different swift version.

Please advice. Thank you in advance!


Solution

  • You need Module Stability, not ABI stability.

    The difference and the way how to achieve Module Stability, are described here: https://www.donnywals.com/what-is-module-stability-in-swift-and-why-should-you-care/

    Here is WWDC session that explains swift binary frameworks (time code: 17:00).

    Briefly, your framework

    • should be built with Build Libraries for Distribution set to Yes
    • set the Skip Install property to No.
    • distributed as .xcframework with variants for simulator and device

    You'll need to ensure that frameworks embedded into .xcframework all have .swiftinterface file inside of Modules/<name>.swiftmodule folder.