Introduction to SwiftUI
A first look at Apple's declarative UI framework, and where to go next after learning the Swift language.
2 min de lecture
Everything in this course has been about the Swift language — the syntax and concepts that apply no matter what you're building. SwiftUI is where that knowledge gets put to use: Apple's modern framework for building the actual interface of an iOS or macOS app, written entirely in Swift.
A minimal SwiftUI view
import SwiftUI
struct WelcomeView: View {
var body: some View {
Text("Hello, Swift!")
.font(.title)
.padding()
}
}A few things here connect directly to concepts from this course: WelcomeView is a struct (recall structs are Swift's default choice, and views are no exception), and it conforms to the View protocol — the same protocol-conformance pattern from the protocols lesson, just applied to something you can see on screen instead of an abstract behavior. The one requirement View imposes is a body property describing what the view displays.
Declarative, not imperative
Older UI frameworks (like UIKit, Apple's previous framework) work imperatively — you write step-by-step instructions to create a label, then set its text, then add it to the screen, then update it manually whenever the data changes. SwiftUI is declarative — you describe what the interface should look like for a given state, and SwiftUI figures out how to make the screen match it, including updating automatically when that state changes:
import SwiftUI
struct CounterView: View {
@State private var count = 0
var body: some View {
VStack {
Text("Count: \(count)")
.font(.largeTitle)
Button("Increment") {
count += 1
}
}
.padding()
}
}@State marks count as a piece of data SwiftUI watches — whenever it changes (here, from the button's closure, another concept straight from this course), SwiftUI automatically re-renders Text("Count: \(count)") to match. You never write code that manually updates the label; you just describe the relationship between the data and the view, once.
Why this feels familiar already
If the syntax above looks approachable rather than intimidating, that's the point of learning Swift itself first: VStack { ... } is a trailing closure, @State private var count = 0 is a variable declaration with a property wrapper attached, and Button("Increment") { count += 1 } combines a struct initializer with — again — a trailing closure. None of the language here is new; SwiftUI is simply Swift applied to a specific, visual domain.
Where to go from here
This course deliberately stopped short of teaching SwiftUI in depth — it's a large framework with its own layout system, state-management patterns, and platform-specific conventions that deserve a dedicated course of their own. But you now have exactly the foundation SwiftUI assumes: optionals, closures, structs, protocols, and generics all show up constantly once you start building real screens. The natural next step is a SwiftUI-focused course or Apple's own tutorials — you'll recognize far more of the underlying syntax than you would have before this course.