Swift UI vs. UI Kit

As my team embarks on creating our iOS app in Swift for the Bike Kollective, the question of which Swift toolkit to use to build the app came up – the newly released Swift UI or the time tested UI Kit? While both have their pros and cons, I thought it might be worth looking into what each offers and how our app could benefit from either.

What is Swift UI?

Though I did take the Codepath Course on iOS app development, that course involved building and working on apps entirely using the UI Kit. So, Swift UI was something mentioned by classmates, but never anything tangible.

From Apple’s own overview of Swift UI, it allows developers to use a declarative syntax to programmatically build their UI elements for app development. This syntax is faster to write and easier to read.

Swift UI Pros

A great point of comparison I found was this blog post which provided several examples of code comparisons between UI Kit code that programmatically creates UI elements and Swift UI code for creating those same elements.

Perhaps my favorite of the examples listed was for programmatically coding a UI Button. For UI Kit, multiple lines of code are required declare the button, add a title for the button, and set it to handle touch events. On the other hand, Swift UI can handle this with a single line that contains label and action logic as parameters.

Swift UI Cons

However, not everything is sunshine and rainbows with Swift UI. Swift UI, after all, was only released in 2019. It’s extremely young, even when compared to the Swift language itself, which was only released in 2014. Therefore, it’s missing a lot of the features one might expect from UI Kit.

In this overview on Swift UI, three main limitations are identified. Apple has yet to implement many of the APIs in Swift UI that already exist in UI Kit. For example, displaying text in an alert isn’t possible to code in Swift UI. While this functionality will certainly come at some point, it’s hard to determine how far out we will have to wait for some of these features.

Another drawback is that Swift UI is only compatible with iOS 13 and later. Any earlier versions of iOS simply will not work with apps built in Swift UI. Not only does that limit the number of devices your app can run on, it limits the viability of the Swift UI skillset when trying to find a position that will utilize those skills. It’s estimated that UI Kit will still be the dominating toolkit for at least the next two years.

Finally, Swift UI’s young age mean it simply has less support for any problems you may run into. UI Kit actually predates the Swift language, as it originally utilized the Objective-C language. Thus, finding help and resources when building your app is significantly easier than doing so with Swift UI.

Conclusion

While Swift UI certainly looks like a worthwhile skill to invest in for the future, I’m not convinced it is the right fit for our project. Our project will require working with a database and dealing with APIs such as Google Maps. These features are known variables when working with UI Kit, but it’s not a given that they’ll be as flexible with Swift UI.

What’s also worth considering is that I’m the only member of the group with any experience in Swift and Xcode, and that experience is all based on UI Kit. Implementing some of the features of this app, especially some of the location features required for bikes and the user, could be particularly time consuming and provide their own hurdles to overcome. I’m not sure it would be wise to add on top of that trying to learn the ropes of an entirely new toolkit.

Lastly, as a Capstone Project, I ultimately find that showcasing my skills in UI Kit is more valuable for prospective employers. If this is going to be the project to show off what I’ve learned through the program, I certainly want employers to be able to recognize that.

That said, for personal projects and other fun side experiments, Swift UI is certainly worth dabbling in.

Leave a comment

Your email address will not be published. Required fields are marked *