Thursday, October 28, 2021

Swift Concurrency for Older OS Versions

Xcode 13.2 Beta:

You can now use Swift Concurrency in applications that deploy to macOS 10.15, iOS 13, tvOS 13, and watchOS 6 or newer. This support includes async/await, actors, global actors, structured concurrency, and the task APIs.

See also: Swift concurrency back deployment. The memory corruption issues are apparently fixed, too.

Previously:

Update (2021-10-29): John Sundell:

Although Swift 5.5’s new concurrency system is becoming backward compatible in Xcode 13.2, some of the built-in system APIs that make use of these new concurrency features are still only available on iOS 15, macOS Monterey, and the rest of Apple’s 2021 operating systems.

[…]

Thankfully, the above problem is something that we can fix ourselves, since Swift’s new concurrency system ships with a continuation mechanism that lets us retrofit existing code with async/await support.

Here’s how we could use that mechanism to replicate the above async/await-powered URLSession API in order to make it available all the way back to iOS 13[…]

Update (2021-12-16): Dimitri Bouniol:

Now that Swift’s concurrency system is backwards compatible with iOS 13/Catalina, here are a few packages you might want to check out!

Update (2022-01-31): Doug Gregor:

For folks using #SwiftLang concurrency on older Apple platforms, Xcode 13.3 beta addresses launch-time crashes reported on earlier OS versions (eg iOS 12, macOS 10.14).

Update (2022-04-27): Ole Begemann:

Boy, this back-deployment of Swift features is complicated.

tl;dr: Critical concurrency bug fixes that shipped in iOS 15.4/macOS 12.3 don’t magically make it into the concurrency runtime used on iOS 13/14.

Comments RSS · Twitter

Leave a Comment