Does Swift 5 runtime support Swift 4.2? 🤔

Xcode 10.2 release notes say the following:

Swift apps no longer include dynamically linked libraries for the Swift standard library and Swift SDK overlays in build variants for devices running iOS 12.2, watchOS 5.2, and tvOS 12.2. As a result, Swift apps can be smaller when they’re shipped in the App Store, deployed for testing using TestFlight, or thinned in an app archive for local development distribution.

To see the difference in file sizes between an app that’s thinned for iOS 12.2 and an app that’s thinned for iOS 12.1 or earlier, set your app’s deployment target to iOS 12.1 or earlier, then create an archive of your app with the scheme set to Generic iOS Device. After building the archive, select Distribute App from the Archives organizer, then select Development distribution. Be sure to select a specific device—such as iPhone XS—in the App Thinning pull-down menu. When the distribution process completes, open the App Thinning Size Report in the newly created folder. The variant for iOS 12.2 will be smaller than the variant for iOS 12.1 and earlier. The exact size difference depends on the number of system frameworks your app uses.

I would think that it comes from the ABI stability of Swift 5.

However if I archive my project still in Swift 4.2 with Xcode 10.2 I can see decrease in app size and missing copy of Swift frameworks in the app bundle of iOS 12.2 slice.

How is that possible? Is the Swift 5 Runtime able to serve apps build with Swift 5 compiler but in Swift 4.2 mode?

I believe that "previous-version" mode of the compiler only changes the syntax that is considered valid, and which APIs are available, due to @available annotations. There is still only one ABI.

If I am correct, then the answer is: yes, the same runtime can support an app compiled in Swift 4.2 mode, as long as it was compiled by the Swift 5 compiler.


That's correct, "Swift Language Version" (-swift-version) has been a mode of the compiler for several releases now, rather than a distinct ABI and runtime.


Thank both of you for the clarification.