Recorded – watch the full episode on YouTube.
Folks learning Swift for the first time often think, “okay, I want to make an iOS app. Should I learn UIKit or SwiftUI?" So what is your opinion on this, Meng? Should a newcomer to Swift take up UIKit or SwiftUI first?
Meng To: I think that's a great question. And I've received this question a lot as well, and I would say that I'm very biased and you should definitely anticipate the answer from me, but definitely SwiftUI.
The reason why is because to me, one of the key philosophy of learning any platform is, how do you get to the maximum results in the least amount of steps possible? And SwiftUI is the answer to that question, right? You can essentially just go to content view, change a few lines of code and you already have whatever it is that you're building right now.
You can use as much a custom layout or something that is building controls such as navigation view and list view and all that stuff. And all of these things such as the button and all of these things. So it's very easy to get to the maximum results in the shortest amount of time.
“I would say that I'm very biased and you should definitely anticipate the answer from me, but definitely SwiftUI.”
But what I see the problem with a lot of tools is that they also follow this philosophy, especially for prototyping tools. The problem with those tools is that the beginning is amazing, it's like the honeymoon period, you're like, “oh my God, this tool is amazing.”
But then you spend a couple of days on it and then a week, and then you realize that they haven't really thought through the whole journey, right? They didn't really brought you all of these powerful things you can do, but with SwiftUI, and that's what I love about SwiftUI is, or anything by Apple, is that they don't just stop at the beginning of the journey, right? I'm still in love as much in SwiftUI right now as I was when I started 10 months ago when it was out.
So I think that's very important for any platform to follow that philosophy, it's not just to say, “hey, we want to have a really great onboarding experience or a really great landing page showing this tool and what this can do.” But also to say, “hey, do you think that the people using SwiftUI are going to stick to SwiftUI in 10 months? Or in two years? In five years?”
“We still love SwiftUI, we love exploring more and more of the updates that Apple brings to us and that's why I would always... I think SwiftUI is the future as soon as iOS 13 is going to be out of the way in term of requirement and we're going to have 90%, 95% device support, I think everyone's going to jump on SwiftUI.”
And I think if you look at what you're doing right now and what I'm doing right now, I think the answer is pretty clear. We still love SwiftUI, we love exploring more and more of the updates that Apple brings to us.
I think SwiftUI is the future as soon as iOS 13 is going to be out of the way in term of requirement and we're going to have 90%, 95% device support, I think everyone's going to jump on SwiftUI. And UIKit is still going to be important and Swift is still going to be important to support whatever SwiftUI cannot do. And I think that's great, that SwiftUI can take the Swift code and make it work and use a lot of the stuff that UIKit can do. And so there's just no way I'm going to go back to UIKit after this.
Paul Hudson: I’ve referred to SwiftUI as the ultimate WWDC framework multiple times, because I think it's really perfect for WWDC because you can get on stage and show a handful of lines of code and it just pow, looks incredible.
And of course it's WWDC so it's very controlled sessions. There's no one there saying, "How do I change the table view inset separator sizes?" Which you can't do in SwiftUI, or, "Where are the text views? Or where the collection views? Or where are the alerts with input text fields?" And so forth. It's great for doing these 40 minutes wow sessions.
“I’m not saying SwiftUI does everything but one thing that it does great at is that it allows you to create these custom layouts, which is something that I've been focusing on. To me, creating a navigation view and stuff like that is easy, but also is not necessarily what I like to focus on for designers who wish to up their game in term of UI.”
But when you live with it for a while, like you said, you've got to realize actually there are some drawbacks here. Things I can't do in SwiftUI currently, but of course you could make a table from scratch if you wanted to, but you want to use the real list if you could, but you can't change some things about it. And that can be frustrating. And that's where the emergency backdoor to UIKit would be really, really helpful.
Sadly there isn't one – you can't say, “okay, this bit you can't do, let me just dig into the table view behind you.” That isn't possible so you have to push to a new screen which is UIKit, and then modify that in UIKit and then go back to SwiftUI for the things that you can't do very easily. That's a little bit frustrating, I think.
Meng To: Absolutely. I'm not saying SwiftUI does everything but one thing that it does great at is that it allows you to create these custom layouts, which is something that I've been focusing on. To me, creating a navigation view and stuff like that is easy, but also is not necessarily what I like to focus on for designers who wish to up their game in term of UI.
Because at the end of the day, when it comes to launching your app, people will always look for something that they're really passionate about in term of what you're trying to create, in term of animations, in term of interactions, in term of concept, in term of new thinking. If you're always, a hundred percent always on the stuff that are built in, and that looks just like another app or another Android app or another web app, then people are going to intrinsically ignore some of the things that they're excited about.
"I think is by design, some of the things we will miss. I don't know if collection view will make sense of the future. Maybe they're going to reinvent collection view in a better way?"
And I think my philosophy is that I should always be able to excite people when I create something. If I cannot excite people when I create something, then there's something wrong with me or there's something wrong with the tool or there's something wrong with the environment at which it inspires me to do that. And so I think you're right: it does not do everything just like any tool. UIKit does not do all of the things that SwiftUI can do. And SwiftUI cannot do all the things that UIKit can do.
And I think that is by design. Some of the things we will miss – I don't know if collection views will make sense of the future. Maybe they're going to reinvent collection views in a better way?
But what I can say is that right now, there's a way to do it. It's more complex than the collection view, but you can still do it. But most importantly, you can do very, very custom layouts. And if you look at the course that I put out there, or the tweets that people put out there about SwiftUI, including your apps, you can see just a range of UI that you can see, that you can find and create using SwiftUI. And I think that's really exciting.
This transcript was recorded as part of Swiftly Speaking. You can watch the full original episode on YouTube, or subscribe to the audio version on Apple Podcasts.
SPONSORED Join a FREE crash course for iOS devs who want to become complete senior developers — from October 18th to 24th. Learn how to apply iOS app architecture patterns through a series of lectures and practical coding sessions.
Link copied to your pasteboard.