Apple lavished attention on all its platforms at WWDC this year. We even got a first look at the all-new Mac Pro. But another announcement, which didn’t grab so many headlines, may prove to be the most important thing to come out of this year’s developer conference: SwiftUI.
SwiftUI promises to fundamentally change the way developers create apps for Apple products. And you don’t need to be a techie to appreciate why it’s such a big deal.
With SwiftUI, Apple lets go of one of Steve Jobs’ last legacies
Before rejoining Apple in 1997, Steve Jobs was CEO of a company called NeXT, which produced a cutting-edge operating system called NeXTSTEP. Applications for NeXTSTEP were developed in a programming language called Objective-C.
Apple purchased NeXT because it needed a shiny, next-generation operating system to replace the aging System 7 that Macs ran on at the time. Cupertino adapted NeXTSTEP to become Mac OS X, which later morphed into the macOS, iOS, watchOS and tvOS we know today.
Even after all these years, if you take a look under the hood, the origin of Apple’s platforms remains clearly evident. The names of the object classes Apple uses in its code start with the letters “NS,” for “NeXTSTEP.”
But now, thanks to SwiftUI, Apple is starting to rid itself of this last NeXT remnant. NSObject and the like could soon be consigned to history. This is also the first Apple API not accessible from Objective-C since the launch of OS X, which could mark the beginning of the end for this venerable programming language.
The advent of SwiftUI really is the end of an era and the start of something new. But what is it all about? And, more importantly, what does it mean for Apple’s end users?
What is SwiftUI?
Up until this week, developers had to use AppKit and UIKit to create apps for Mac and iOS. These APIs provide the tools developers need to produce user interface elements like buttons, scrolling lists and input fields. With their origins tracing way back to NeXTSTEP, these APIs are starting to show their age.
As software gets older, it acquires what techies call “technical debt,” meaning that while it may be easy and familiar to use, you’d be better off investing the time necessary in switching to a better, more modern approach. And that kind of switch is exactly what SwiftUI is all about.
When Apple introduced Swift, the successor to Objective-C, back in 2014 at WWDC, it was billed as being “completely native to both Cocoa [AppKit] and Cocoa Touch [UIKit].” And thanks to Cupertino’s technical wizardry, it was. Sort of.
Apple has always been great at transitioning smoothly from one technology to the next. When the company made the jump to OS X, it included the Classic and Carbon frameworks so old apps remained compatible. Likewise, with the switch from PowerPC to Intel chips, the Rosetta system seamlessly translated instructions from the old to the new chip.
Similarly, Cupertino did a great job of making AppKit and UIKit compatible with Swift. But you can tell that the APIs are old and approaching their sell-by date.
SwiftUI enables Apple to do away with the NeXTSTEP legacy once and for all, replacing it from the ground up with a new, native API for Swift development.
What’s so great about SwiftUI?
It may be new and different, but what is really so great about SwiftUI? There’s plenty for developers to love about it. But for regular Apple customers like you and me, there are three main benefits we can expect: more apps, better apps and better support for Mac and Apple Watch.
1. More apps: Attracting a new breed of developers
2. Real native apps: Encouraging developers to ditch cross-platform APIs
Why? Because they require loads of extra code, in the form of third-party libraries, to make them work. As a result they tend to be larger, more sluggish and more demanding on system resources and battery than apps built using Apple’s tools. They rarely feel like real native apps.
With SwiftUI, Apple is giving developers one less reason to resort to cross-platform APIs. It’s much quicker and easier to develop in and, with its declarative syntax, it’s easier for React developers to adopt.
3. Better Mac and Apple Watch support: Enabling developers to use code cross-platform
Developers could always reuse code across Apple’s platforms, because they all support Objective-C and Swift. But until this week, they could not reuse user interface code. That’s because each platform has its own framework for that. Mac uses AppKit, iOS uses UIKit, and watchOS uses WatchKit. For an app to work on all three platforms, the developer needs to produce three separate versions of the user interface code.
SwiftUI promises to change all this, because the same framework is native on all Apple platforms. In practice, it is unlikely to be quite that simple because each platform has its differences. An app optimized for the expansive screen of an iPad Pro would not easily adapt to the tiny dimensions of an Apple Watch.
Nonetheless, by enabling developers to reuse more user interface code across platforms, in the long term SwiftUI could prove to be just as important as Project Catalyst in encouraging developers to embrace all of Apple’s products.
When can we expect to see apps built in SwiftUI?
Right now, SwiftUI is in beta as part of Xcode 11. Developers will be playing around with it and kicking the tires for a few months before they actually start building real apps in it.
Xcode is likely to emerge from beta in September with the launch of iOS 13. And that’s when SwiftUI development will really get started. Even then, it’s possible that the framework will not be feature-complete, meaning developers may continue to rely on AppKit and UIKit if the APIs they need are not yet available in SwiftUI.
It could also take a long time for developers of big, complex apps like Photoshop to make the switch. So AppKit and UIKit will hange around for a while.
Nonetheless, there is no doubt that SwiftUI is the beginning of an important new chapter for Apple. In the long run, we can expect to see benefits not just for developers but for everyone who uses Apple products. This week could go down in history as a very major milestone for Apple. Something that 10 years from now, our very own Luke Dormehl will memorialize in a “Today in Apple history” post.