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 Are you tired of wasting time debugging your Swift app? Instabug’s SDK is here to help you minimize debugging time by providing you with complete device details, network logs, and reproduction steps with every bug report. All data is attached automatically, and it only takes a line of code to setup. Start your free trial now and get 3 months off exclusively for the Hacking with Swift Community.
Link copied to your pasteboard.