Updated for Xcode 15
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.
BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.