SwiftUI is becoming better and better. So the question arises for new iOS developers whether UIKit is still relevant enough to learn it.
I started learning iOS development back in 2011. At that time, iOS apps were still developed with Objective-C — no automatic reference counting and no auto layout were available at that time. So a lot has changed over the years. Then came Swift and it was a big change. But now there is SwiftUI and it’s an even bigger step. But does that mean that you shouldn’t learn UIKit?
Let’s start by looking at a poll I recently made on LinkedIn:
So more developers would use SwiftUI in a new app project. But the difference is not big — at least 41 percent voted for UIKit. There seem to be still good reasons for using UIKit — even in a new app project.
Of course, the topic is also a little bit subjective. Here are the reasons that I believe are the advantages of UIKit and SwiftUI respectively:
- Most existing apps use UIKit. So if you start working as an iOS developer, it’s very likely that you will work on projects that use UIKit.
- Over the years many resources like blog posts, open-source libraries, and tutorials have been created. And they use UIKit. Sure, there are more and more resources that use SwiftUI, but it will take some time until the older resources are not relevant anymore.
- For complex layouts, UIKit is still the better choice. SwiftUI is much younger than UIKit and the API coverage is still better in UIKit. Especially when the UI requirements are very strict, you have more options with UIKit.
- For SwiftUI you have to choose a high deployment target. The minimum is iOS 13, but higher is even better. One could argue that this is not a big deal for an iOS app because most users are on the latest iOS version. However, if you have an app that has a big audience you want to have a low deployment target.
Subscribe to ThomasHanning.com
- "iOS Dev & Swift Email Newsletter" - The newsletter of curated iOS development and Swift resources from around the web.
- Get the latest blog posts from ThomasHanning.com directly into your inbox
- Write comments
- Development is less error-prone: SwiftUI is a declarative UI framework. That means you don’t have to handle all possible UI states on your own. As a result, complexity decreases and you will have fewer bugs.
- Development with SwiftUI is faster: Because of its declarative nature, it’s also quicker to develop with SwiftUI. Additionally, you have the preview feature in Xcode which saves a lot of compile time.
- SwiftUI is easier to learn than UIKit because you have much less boilerplate code. Just compare the implementation of an UITableView with a List in SwiftUI. It’s a huge difference in complexity.
We see that both frameworks have their place, but obviously, SwiftUI is the future. Therefore, we are in a transition phase. Many people compare this with the transition from Swift to Objective-C because there are a lot of similarities: Both languages can be used in the same project, one is the future and the new one has a lot of advantages. Also worth noting is the fact that Swift was at the beginning difficult to use because of the bad Xcode integration. For example, code completion crashed all the time so it was quite difficult to develop with Swift at the beginning.
But in the end, the transition from Objective-C to Swift was fast. I believe that the transition from UIKit to Swift will take much more time because the transition is more complex. Probably UIKit will never become as irrelevant as Objective-C is today.
The Biggest Similarity
Before we conclude let us acknowledge one important fact: Both SwiftUI and UIKit are great frameworks and you can create outstanding and meaningful iOS apps with both of them. So in the end it’s not even possible to make a completely wrong decision.
SwiftUI is the future of iOS development but UIKit is still very relevant today and will be for some time. So if you want to become an iOS developer you have to learn both. On the other hand, SwiftUI and UIKit are very complex. Therefore, it’s tricky to learn both at the same time.
My advice is to focus on SwiftUI in the beginning because it’s easier to learn. After you’ve learned the basics and can write simple apps, it’s a good time to learn UIKit.