Swift Concurrency, Combine, and Core Data
Today is the last day of WWDC and like every year, the week of WWDC went by faster than I can watch the videos and study the contents.
This year, Apple announced a major new Swift feature which is Swift Concurrency. This feature overhauls the way we write asynchronous code, and the Swift team has essentially rewritten the way Swift deals with concurrency by introducing a new threading model. My focus has mostly been on Swift Concurrency related videos, and I’ve started going over all of the concurrency proposals to make sure I don’t miss anything.
Unfortunately, Swift Concurrency will only be available on iOS 15 and above for the time being but that won’t stop me from diving deep into it in the coming months.
With Swift’s new concurrency features, a lot of other frameworks and APIs have been overhauled either automatically by automated translations from Objective-C to Swift, or by the respective teams. Core Data is such a framework that has received some nice updates to make it work nicely with Swift Concurrency. I’ll be exploring this over the coming weeks so I can update my Practical Core Data book (for free). In addition to Swift Concurrency support, Core Data’s CloudKit integration received some attention to. In iOS 15 NSPersistentCloudKitContainer has support for CloudKit sharing, so make sure to look out for that in the next update of my Core Data book.
Combine was one of the most notable absentees this week which led to a lot of questions and confusion amongst Combine enthusiasts. Is Apple deprecating Combine? What’s Combine’s place in an async / await driven world? Should we stop using Combine?
The short answer, I think, is that Apple is happy where Combine is and that async / await will impact it mostly in areas where Combine was used as an asynchronous task runner rather than a way to observe state and react to state changes. In the links section for this newsletter I’ll link to a post I wrote on Tuesday that explains my initial thoughts around Combine in async / await world.
I honestly wish Apple had at least mentioned Combine and how we “should” use it in iOS 15 to provide us with some context instead of letting us figure out Combine’s place on our own. Or maybe Apple not saying anything says a lot? I don’t know.
I do know that I will be updating Practical Combine soon with some improved examples that might reflect its place in an async / await world better. And I’ll also make sure to mention async / await as an iOS 15+ alternative when relevant. I’m sure that a lot of folks are currently supporting iOS 13+ so it would not make sense for me to remove certain examples completely in favor of async / await. Of course, the Practical Combine update will be made available for free, just like the Practical Core Data update.
ps. I bought a new domain name this week.