I’ve always enjoyed the days after a WWDC Keynote. It’s a mix of excitement and anxiety over the new refinements/features/frameworks and all the learning and work those entail. This year is no different… except those feelings are amped up to 11!
The keynote was pretty good over all with solid incremental updates on all platforms. Standalone watch apps, Dark Mode and the new Photos.app on iOS, “windows” and USB drive support on what’s now called iPadOS, sidecar and iTunes dismantling on macOS, etc.
And, of course, there’s the new Mac Pro. Everything about the Mac Pro sounds ridiculous… from the specs to the price. I’ve never owned a Mac Pro and never felt like I needed to. And although that certainly hasn’t changed, I view this announcement as Apple course-correcting on who the target audience of the Mac Pro really is – multi-media professionals and research. And I’m sure there are many developers out there wishing for a user upgradable/expandable machine… I’m just not one of them.
But enough about that. I want to talk about the star of the show: SwiftUI.
Going into this WWDC I was most eager to learn about
Marzipan Project Catalyst and whether it would ever unify the UI frameworks on macOS and iOS. But after learning about SwiftUI… I couldn’t care less.
Surprisingly the SwiftUI announcement only took 10 minutes on a 2.25 hour keynote. To me, this should have been this year’s “one more thing”.
Throughout my career as a developer on Apple platforms there have been many important milestones that really changed how I did my job. I’m thinking about blocks, ARC, Auto Layout, Swift… and now SwiftUI.
So what’s the big deal with SwiftUI? Well here’s why I think it’s great.
One UI framework for all platforms
It has always baffled me why Apple never made UIKit work on the Mac. If it worked for iOS and tvOS it could certainly also work on the Mac (which it does now thanks to Project Catalyst). For me this means having double the work on many parts of the UI on Secrets for Mac and iOS.
Now and then, you would see rumours that would give you hope. “Maybe next year” you’d think… but the years passed and nothing. Looking back, I can’t help but wonder if this was Apple’s plan all along. SwiftUI is certainly a multi-year effort. The underpinnings of the combine framework are at least 5 years old:
I was curious what the earliest Combine-related file I have on my computer is, and it turns out it's August 14th 2013. I filed the radar it references on 10/23/2012.— David Smith (@Catfish_Man) June 5, 2019
Also apparently yet another short-lived project name I forgot about?? pic.twitter.com/FR6NADWrs5
And although I haven’t played much with it yet certainly there’ll be lot of bugs/shortcomings to iron out for next few years.
To put it succinctly, this means that instead of telling the framework what to do you tell it what you want. The framework then figures out how to achieve. And you’ve seen this style of coding already with Auto Layout. It offloads much of the complexity to the framework.
By introducing this abstraction and letting the framework do the job of composing the UI for you we get:
- Automatic support for many of the system features: dynamic type, accessibility, dark mode, etc;
- Adaptive layouts on different platforms (a switch on the iPhone becomes a checkbox on the Mac);
- Freedom from having to adapt our UI whenever Apple needs to evolve it (what SwiftUI uses to satisfy a
Textelement may change on the next release).
I had a professor that used to say:
All problems in CS can be solved with one more level of indirection.
It still holds.
I’ve never invested much time with any of the reactive frameworks out there. I definitely appreciated the principles behind them but I’ve always been very critical of frameworks1 or technologies2 that are too invasive.
With what I’ve already seen on the sessions and demos, I’m just about ready to forgive Apple for abandoning development of the controversial Cocoa Bindings3.
We write so much glue code that I’ve got no problems accepting the learning curve of all the new stuff that is driving this both in the Swift language and the new Combine framework.
I’m cautiously excited about SwiftUI and sincerely hope it will live up to expectations.