Updated for Xcode 14.0 beta 1
When you’re just learning Swift and SwiftUI the first time, you might look at Swift and SwiftUI and imagine that they are two competing choices for you to pick from. So, it’s perfectly understandable to ask what’s the difference between Swift and SwiftUI, and which should you choose?
Well, the reality is a little confusing, at least at first: you need them both. Swift is a programming language, which mean it’s the words we type into our computer to say what our program should do. Swift can be used in many places, but it’s mostly used for building apps on Apple’s platforms – iOS, macOS, watchOS, and tvOS.
On the other hand, SwiftUI is a set of tools that let us describe and control user interfaces. It knows what a button is and how it can be tapped by the user. It knows how to let users enter text. It knows how to show images, select dates, respond to swipe gestures, and much more.
Building an app is the process of writing Swift code to control SwiftUI. Swift is the language saying “I want a button here, and a text field here, and an image over there,” and SwiftUI is the part that actually knows how to make the button, how to draw the text, and how to load and show the image.
Almost all of this book focuses on Swift, with SwiftUI only getting small mentions here and there. This is because the goal of the book is to help you understand how the pure Swift language works, so you can use it with SwiftUI or indeed with any of Apple’s other user interface choices.
SPONSORED In-app subscriptions are a pain to implement, hard to test, and full of edge cases. RevenueCat makes it straightforward and reliable so you can get back to building your app. Oh, and it's free if your app makes less than $10k/mo.
Link copied to your pasteboard.