Your First iOS & SwiftUI App: An App from Scratch
Jan 11 2022 Swift 5.5, iOS 15, Xcode 13
Part 1: Getting Started with SwiftUI
2. SwiftUI vs UIKit
Leave a rating/review
The order of the courses in the beginning learning path mentioned has changed; see the current order here
There’s a saying erroneously attributed to the Chinese: “May you live in interesting times.”
Depending on your point of view, that can be either a blessing or a curse. And right now, this saying accurately describes the situation that beginner iOS developers find themselves in today.
In 2019 Apple introduced SwiftUI, which is the hot new way to create user interfaces in Swift. One of the cool things about SwiftUI is that your user interfaces are created completely in code, but while you’re coding you can see a dynamic preview of this code in SwiftUI’s canvas editor. And you have a choice - you can either code the user interface yourself, or you can use Swift UI’s canvas editor to code it on your behalf.
This is nice because SwiftUI gives you the benefits of being able to construct a user interface via code, combined with the benefits of being able to visualize your work as you go. It also makes working with SwiftUI really nice in real-world, team-based environment.
Apple has been promoting SwiftUI as the preferred way to build new apps for many reasons, including the fact that it makes it easier to port your iOS apps to Apple’s other platforms, such as macOS, watchOS and tvOS.
Plus, it’s plain fun! As you’ll see for yourself in this course, creating beautiful user interfaces with SwiftUI is a pure joy.
It’s important to know that SwiftUI isn’t the only way of making user interfaces on iOS. You can also use something called UIKit, which is the framework that iOS developers used before SwiftUI was released.
I want to point out that UIKit is still a valid way to make iOS apps, even though SwiftUI is released. In fact I’d say that today, there’s still more developers using UIKit than SwiftUI.
If SwiftUI is so great, why is that?
Well, there are three main reasons.
First - SwiftUI only works on iOS 13 or later. Even though iOS 14 is out now, some companies still need to support iOS 12 or earlier, so they can’t switch to SwiftUI quite yet.
Second - SwiftUI is still not as mature as UIKit. Think about it: UIKit has been out for 12 years, and in fact it was based on a macOS framework called ApplicationKit which had even more history, so there was a lot of time to get things right.
But SwiftUI is less than 2 years old. This means there are still some missing features or rough edges. So some companies want to give SwiftUI a little more time to mature.
Third and finally - many companies have already written their apps using UIKit, and it would simply be too much work at this point to rewrite the entier thing in SwiftUI, so a lot of that old UIKit legacy code will remain.
So now it comes time to answer your burning question…
…which should I learn: SwiftUI or UIKit?
As of today, here’s our answer.
If you’re serious about being a professional iOS developer, our recommendation is to learn both SwiftUI and UIKit.
Learning SwiftUI is important because it’s the future of iOS development. SwiftUI is huge, and there’s a lot to learn, so it’s a good idea to get started now. And if you’re making a new app, you can make it with SwiftUI today.
Learning UIKit is important too. If you end up working at a company that already has shipped an iOS app, there’s a high chance that it’s been made with UIKit. So if you want to work at one of those companies, it’s important for you to be able to work with those codebases too.
I also want to point out that it’s not all or nothing: it’s possible to make a certain part of your app with SwiftUI, and the rest with UIKit. As companies begin to transition from UIKit to SwiftUI, we expect to see many codebases with a mixture of both SwiftUI and UIKit code in the years ahead.
But don’t worry - we’ve got your back, and we have a plan for how to teach you everything you need to know.
This year, we are updating all of our learning paths at raywenderlich.com with a SwiftUI-first approach. This means that all of our learning paths will use SwiftUI for all sample project, with one exception which I’ll talk about in a moment.
We decided upon a SwiftUI-first approach because SwiftUI is the future of iOS development. This way can be sure that you’re learning the latest and greatest techniques, making your skills future-proof and in high demand.
Right now, you’re in the first of our learning paths, titled iOS and SwiftUI for Beginners. This learning path has five courses:
First, there’s the course you’re in now: Your First iOS and SwiftUI App: An App from Scratch. In this course, we’ll work through the “must haves” in our programming to do list to create a minimal viable product for Bullseye.
Next up its sequel: Your First iOS and SwiftUI App: Polishing the App, where you’ll implement all of the “nice to haves” in our programming to-do list, which largely is focused on making the app look pretty.
In that course, you’ll learn how to take the app from the minimal viable product in the upper left, to the polished app in the lower right. Pretty cool, huh?
For your third course, you’ll move on to Programming in Swift: Fundamentals, where you’ll take a break from app development to focus on the fundamentals of the Swift programming language.
Now that you have a firm grounding with the Swift language, you’ll get back to iOS and SwiftUI with Your Second iOS and SwiftUI App.
For your second app, you’ll create an entire personal library-tracking app, using SwiftUI.
This app will be a fair bit more complicated than Bullseye, and you’ll learn more about working with lists of data in your apps, passing data across your app, and much more.
And for your fifth and final course, Programming in Swift: Functions & Custom Types, you’ll return to the Swift programming language, but this time take a deeper dive into areas you’ll need to know on a day-to-day basis as a Swift developer.
And guess what - that’s only the first learning paths! Once you’ve completed the first learning path, you can move onto more advanced learning paths, like iOS User Interfaces with SwiftUI, iOS Data and Networking, and iOS IDEs and Tools.
All of these use SwiftUI. But what about UIKit? As we mentioned, it’s important to learn that too.
That’s why we created a special and optional learning path, called iOS User Interfaces with UIKit. If you need to learn UIKit development for your job, you should definitely check that out. But if you only care about SwiftUI, you can safely skip it.
So for new iOS developers having to learn two ways of creating user interfaces at once, these are definitely some interesting times.
But hey - learning new things is part of the joy of being a programmer. We’re loving learning SwiftUI and are so excited to be on the cutting edge of the future, and we hope you enjoy this journey with us!