What's difference bewteen Swift Language version, Swift runtime version, Swift toolchain version, iOS SDK version and iOS deployment version

when i read this blog about ABI Stability, got some confused, consider this scenario:
Use Xcode11, which with Swift 5.1, build a project which Swift language version is setted Swift 4.2, and run project at iOS 12.4, which embedded Swift 5.0 runtime in OS, is it weird? I think Swift standard library should be dynamic link of APP, so what is the role of Swift toolchain version duration build exactly? is it participate Link Phase?

1 Like

The toolchain version is the version of the tools you're using, typically determined by the version of Xcode you have installed. "Tools" includes the compiler. There's generally no reason to use an older toolchain to build; newer toolchains have more bug fixes, performance improvements, and features.

The iOS SDK version is the iOS release that the SDK you're using was derived from. This is also typically determined by the version of Xcode you have installed. You can still build code that works on older releases of iOS if you're using a newer SDK; like toolchains, there's generally no reason to use an older SDK to build.

The language version is the language compatibility mode you've asked the compiler to use. Building your code as Swift 4 in Xcode doesn't actually switch to a Swift 4 compiler, it just tells the compiler to try to apply the same language rules that the Swift 4 compiler would have used.

The iOS deployment version is the minimum release of iOS that your app supports running on. This affects what APIs you can use without checking availability; it also sometimes affects the compiler's code generation.

The runtime version is the version of the Swift runtime you're using, which is determined by the version of iOS your app is actually running on. This affects what language features you can use in your app. Since we've only had one iOS release since Swift reached ABI stability, this can currently only be either 5.1 or 5.2, but of course there will be more iOS releases in the future, each with newer versions of the Swift runtime. iOS releases before iOS 12.2 don't include an ABI-stable runtime at all, so the 5.1 runtime is bundled with your app if your iOS deployment version is older than that.

15 Likes

Thanks! It's very clear.
Still got some confuse, here is my understand:

  • toolchain include compiler tools such as swiftClang, llvm, lldb. used to compile and debug my own code.
  • and Swift runtime is a bundle of binary code include swift foundation, libdispatch, stdlib, which is a concept of language layer.
  • and iOS SDK is some dynamic lib like UIKit, WebKit, MapKit and so on.which is a concept application layer.

is that right?

For existing code, this is false, especially on Linux. Every new compiler version doesn't just fix existing bugs, it often adds new ones. This has been my experience with every upgrade so far.

Making things even more subtle, the SDK is the version of those dynamic libs that’s used at link time, but that’s not the same as the version of those libs whose code actually runs in your app. The former is decided by the version of Xcode, but the latter is decided by the version of OS the app is actually running on.

This is a frequent source of confusion because it leads to people incorrectly assuming that recompiling with a new Xcode is what gets them new UIKit (etc) behaviors, when in fact 90% of the time it’s because they’re running on a newer OS.

To make things even more subtle, the OS can and occasionally does detect which applications have been recompiled with newer Xcodes (and therefore had the opportunity to be tested with the corresponding newer OS), so sometimes it’s a combination of both.

4 Likes
Terms of Service

Privacy Policy

Cookie Policy