Photo of the Transpire Brand

Here’s What You Need to Know About SwiftUI

At this year’s Apple Worldwide Developer Conference (WWDC), many developers (myself included) were expecting an update on the previously announced ability to port iOS applications to MacOS (known by many as project Marzipan with the official launch title of Catalyst). 

Little did we know that Apple had something much bigger planned – the announcement of SwiftUI, which took centre stage and set the foundation for what many claimed was one of the best WWDCs for developers in a long time.

How did SwiftUI come about?

Swift the programming language was released five years ago, giving developers the ability to write clean, simple, safe and fast code. Prior to this, iOS applications had to be built in a language called Objective-C, which didn’t have any of the nice features we’ve come to know and love from Swift. 

Upon its release, the far-reaching benefits of Swift were obvious – the fact that Apple made Swift open source was not only a clear indication of its importance, but also a way for as many developers as possible to use it. 

However, one of the fundamental problems with Swift was that Apple had only really focused on the language itself. This meant you needed to go back into Objective-C to create a link between Swift code and the user interface. 

Enter SwiftUI…

What exactly is SwiftUI?

SwiftUI is a whole new way for developers to handle and interact with UI components. It has been written from the ground up with a declarative Swift syntax that’s easy to read, natural to write, and works seamlessly with Xcode design tools like the new Canvas.

What’s really nice about SwiftUI’s new components is that they take so much of the heavy lifting away from the developer and onto the OS, which enables developers to keep doing what they love doing. 

Essentially, developers can now build user interfaces for any Apple device using just one set of tools and APIs. As a result, users benefit from a seamless experience across Apple’s ecosystem at every touch point. 

What are the benefits of SwiftUI for businesses?

1. Easier prototyping and POCs 

SwiftUI allows you to build a list with just three lines of code. Previously, you were looking at more like 10 lines of code, not to mention linking to your designs and implementing the required protocols. New drag and drop functionality also means arranging and organising components is significantly more straightforward. Even though it’s still possible to code parts of the interface, you can use inspectors to discover new modifiers for each control, all of which allows for easier prototyping and proof of concepts.

2. Fewer hired hands

SwiftUI practices the ‘learn once, apply anywhere’ methodology. Therefore, if you’re an iOS developer that wants to build a macOS app, you’ve already got the skills and tools to do so. By providing every type of developer with the ability to create any type of Apple application, SwiftUI (in theory) reduces the recruitment load on businesses, as specialist skill sets are no longer required.

3. Rapid MVP development

Because the same code can be used for every Apple OS, developing multiple applications is more seamless and easier to implement. You can also get going really quickly thanks to updated system components like System Fonts and System Colours as well as out-of-the-box features like Dark Mode, right-to-left language support and targeting for all device sizes. Say goodbye to wireframes and constraints; hello to rapid MVP development.

Intuitive new design tools in Xcode make building interfaces with SwiftUI as easy as dragging and dropping.
Intuitive new design tools in Xcode make building interfaces with SwiftUI as easy as dragging and dropping.

4. Appeal to more users

Accessibility labels and components can now be bound and updated with state changes. This is a huge win for accessibility because it reduces several responsibilities for developers, which are often pushed down the priority list during projects when things like time and budget come into play. By giving precedence to inclusive design, SwiftUI is helping more users experience and engage with Apple applications. 

5. Great looking applications. 

SwiftUI really forces you to closely align with Apple’s design guidelines. It even handles some of this for you. While this may sound like a hindrance, it actually allows for a more familiar, consistent and intuitive user experience across every Apple touchpoint. Users can focus on the application’s content instead of worrying about poor designs or bad layouts.

What are the benefits for developers?

1. Safer code quality. 

Many elements force bindings to code by default and views only have one execution path, which means developers can rest assured that their view layouts will be rendered as expected.

2. Less work required

From animations and transitions to formatting and appearance, the operating system handles all the hard stuff for you. So, when using SwiftUI, all you have to do is state the end goal of your interface and the OS maintains everything else. This unified experience for all applications means that your design will tick those all important Human Interface Guidelines, and hopefully lead to faster and safer releases. 

Code is simpler and easier to read than ever before, saving developers time and maintenance.
Code is simpler and easier to read than ever before, saving developers time and maintenance. 

3. Cross-platform user interface

Seeing as SwiftUI works across iOS, iPadOS, macOS, tvOS, and even watchOS, you only have to learn one language and one layout framework, then deploy your code anywhere. Your interface will adapt to match the Apple product it’s being used on with very little effort, allowing you to spend much less time optimising for each individual platform.

4. Real-time previews

Developers can see real-time previews of how their code is linking and modifying their views behavior. You can drag a font color object onto the canvas preview or in the code itself and see it change instantly. There are no limitations either – you can preview all of the devices you support in light and dark mode, and in different languages, straight out of the box. 

What’s not so great about SwiftUI?

1. Latest OS versions required

In order to use SwiftUI, you need to be targeting the latest versions of iOS (iOS 13) and MacOS (10.15). Support for older versions might take a while. 

2. Limited documentation and resources

For a recent innovation that’s currently in beta, it’s hardly surprising SwiftUI doesn’t have much supporting documentation or many resources. While this is sure to improve, getting the ball rolling without any guidance or reassurance can be quite challenging.

3. Change of mindset. 

Developers should understand that SwiftUI requires a different approach to what they might be used to – everything is declarative and there’s now bindings to objects (with a whole new framework for this called Combine). So for many, SwiftUI will be unchartered territory. 

Its possible to integrate SwiftUI views with objects from the UIKit, AppKit, and WatchKit frameworks to take further advantage of platform-specific functionality.
Its possible to integrate SwiftUI views with objects from the UIKit, AppKit, and WatchKit frameworks to take further advantage of platform-specific functionality.

Where is SwiftUI heading?

Over the next few years, the Transpire iOS team and myself feel as though SwiftUI will start to become the norm – just like what Swift did to Objective-C. There are so many benefits and it’s clear that Apple has been intending to go in this direction since the launch of Swift.

There will still be certain applications (larger, older applications) that won’t support it, but SwiftUI is sure to be the starting point for most projects as early as 2020. 

How can I adopt SwiftUI?

You can already use SwiftUI fairly easily alongside UIKit. However, Apple recommends adopting it at a screen-by-screen level for existing applications to address the learning curve issue. To get started, you’ll also need to be running beta versions of the software to get started. 

My personal recommendation would be to strongly consider SwiftUI if you’ve got the time and inclination to get to grips with its unique differences. Along with reaping its rich rewards, you’ll also ensure your projects are always up to date and be ahead of the curve when everybody else starts using SwiftUI. 

To capitalise on the merits of SwiftUI for your next application, get in touch with us today.

Photo of the Transpire Brand

Sign up to receive all the latest insights.

MORE POSTS

Stay up to date with the latest news, events and insights...