Which of Swift 5.1 features are backwards deployable?

It's first worth distinguishing "the Swift runtime and standard library" from "the SDK". Combine, SwiftUI, CryptoKit, and RealityKit are frameworks written in Swift, but they're not part of the Swift Open Source project. They're more like ARKit, MapKit, and Intents: part of Apple OSs, made available for use by apps via Xcode and its SDKs.

Stepping beyond that, an SDK doesn't contain enough information to run things; only to build them. There are many reasons for that, but fundamentally it comes down to some changes having to happen in the operating system itself—either because the changes actually need to be in the kernel, or because something OS-internal has changed in a non-backwards-compatible way.

So Xcode 11 on macOS Mojave can't run apps that use Catalina features like Combine. However, what is part of Xcode is the simulator, and so you can write apps for iOS 13 and try them out in the simulator. And playgrounds are built on top of the simulator, so you can experiment there too (as long as the playground is building for iOS or tvOS and not macOS).

9 Likes

Interesting…so if I'm understanding you correctly, you can write apps for iOS 13 or tvOS 13 and try them out in the Xcode 11 simulator on macOS Mojave, but you can't write apps for macOS Catalina and try them out in the Xcode 11 simulator on macOS Mojave (i.e. the only way to try out apps for macOS Catalina is to install the macOS Catalina beta). Is that right?

2 Likes

macOS doesn't have it's own simulator, otherwise we'd need a Catalina simulator for Mojave. :wink:

1 Like

As far as I know if an applciation supports iOS below 12 Swift runtime is bundled with the application. In the future when I finally will be able to drop support for iOS below 12 my application will be bundled with Swift X runtime which is newer than Swift's runtime bundled with iOS 12. What will happen to my project if I use features which are not supported by Swift 5's runtime?

The runtime that's bundled with your application is always the Swift 5.0 runtime, partly to avoid discontinuities ("iOS 11 supports Swift X but iOS 13 only supports Swift 5.1?") and partly because the Swift 5.1 runtime can drop support for older OSs that way and therefore do additional optimizations.

(EDIT: I don't know if we actually do any of those optimizations in 5.1, but it's possible now, and the runtime folks certainly have several in mind.)

5 Likes

Does swift 5.1 runtime not have support for ios12? Is it a technical limitation that 5.1 can’t be included with the app for back deployment?

It happens to work right now, but that's not a promise going forward. The problem is less iOS 12, the current major GM release, than iOS 7, the oldest release Swift supports.

Were you all able to get opaque result types to be backward deployable?