Back in 2019, Apple made the bold decision to create SwiftUI as the natural successor to UIKit and completely shake up the iOS development space. Since it’s announcement, the rate of adoption has been rather slow. Companies are slightly reluctant to make such a drastic change to their already established codebases and so for now, UIKit remains the main way by which iOS apps get made. Eventually however, SwiftUI will take over and it is important to have knowledge of it ahead of time. This article will look at the reasons behind the introduction of SwiftUI and it’s potential advantages over UIKit.
A Look Back
Apple first introduced Swift at WWDC14. A modern rethinking that borrowed a number of ideas from popular languages, Swift was described by Apple as “an industrial-quality programming language that is as expressive and enjoyable as a scripting language.”
Swift can be used to create UIKit apps for iPhone, iPad, AppleTV and Apple Watch. However the UIKit development API precedes the creation of Swift. Apple sought to create a framework through which they can harness the true power of Swift. This is where SwiftUI comes in. SwiftUI delivers a refined approach to building the code that drives the look and feel of apps, promising to dramatically increase developer productivity.
Why SwiftUI? Advantages over UIKit
SwiftUI also has a feature similar to the Hot Reload feature available in Flutter, where code is instantly presented in a graphical preview as you type it. This works because XCode recompiles changes instantly and inserts them into a running version of your app, visible and editable at all times. SwiftUI supports drag-and-drop arrangement of UI components within the user interface by simply dragging controls on the canvas. Once placed you can easily rearrange controls or click to open an inspector to select font, color, alignment, and other design options. Even if you prefer hand-coding parts of your interface, you can use inspectors to discover new modifiers for each control. You can drag controls from your library and drop them on the design canvas or directly on the code.
One of the key reasons behind the creation of SwiftUI was the desire for developers to be able to bring more complex ideas to life. SwiftUI makes programming more accessible to a larger audience of users, including people who have an idea for an app but lack the skills to build software. In making its development tools easier to learn and simpler to use, Apple can continue to expand its base of developers globally, offering them the most lucrative store to sell their apps, along with the best accessibility and localizations needed to reach audiences around the world.