SwiftUI Essentials
Building an iOS interface with SwiftUI is not difficult because the syntax is unfamiliar, it is difficult because the framework asks you to answer questions that UIKit never asked. A UIKit view controller owns a hierarchy of objects and tells them when to change. A SwiftUI view is a value that is thrown away and rebuilt every time something it depends on changes, so before you can write a screen that behaves, you have to decide who owns the data, who is allowed to change it, and how the framework is supposed to know that it needs to look again. Get that wrong and you get the two symptoms that every SwiftUI developer meets early: a value that changes but the screen does not move, and a value that moves the screen but forgets itself at the wrong moment. This course is built around getting past that, and then around everything else that a real application needs.
The material is divided into three large movements, and each one assumes the previous one. The first teaches the view system itself: how an application starts, what a view is, how views are arranged and modified, how images and symbols are loaded, and how you look at your work in the preview canvas without launching the app. It also introduces state in its simplest form, so that the second movement has something to build on. The second movement is about ownership. It works through the property wrappers one at a time, explains what the modern Observation framework changed and what it did not, shows how the environment fits in, and then treats the questions that are really about judgement rather than syntax: how state behaves across view identity changes, how to stop it from spreading through an entire application, how to run asynchronous work that cancels itself when it should, and how to drive a navigation path from a deep link. The third movement is about the screen the user actually sees: navigation, lists and forms, the standard controls, the three ways to present something on top of what is already there, custom layout through the Layout protocol, drawing with Canvas, animating with TimelineView and matched transitions, the accessibility contract that a shipped app has to honour, and the tests that keep all of it honest.
Read them in that order. The state chapter is useless before the view chapter, because you cannot talk about a property wrapper until you know what a view is and what it means for a view to be rebuilt. The interface chapter is much easier after the state chapter, because almost every interesting screen has to hold something: an expanded row, a selected tab, a sheet that has been dismissed, a value that came back from a network call. The three chapters also share one habit. Each of them ends by taking a screen apart and asking where the state should have been, because in practice the fastest way to understand a SwiftUI rule is to watch a view break when the rule is broken.
The prerequisites are modest but real. You should be comfortable with Swift itself: value and reference types, optionals and the difference between nil and an unwrapped optional, closures, protocols and protocol extensions, and enough generics to recognise a type you have not met before. You do not need to know SwiftUI, and you do not need any experience with UIKit, though if you have written a UIKit app you will find that the comparisons are useful. You will need a Mac with Xcode 15 or later, which means macOS Ventura or newer, and either a simulator or a physical device running iOS 17 or later. Every example in the course is written for Swift 5.9 and iOS 17, and where a newer API replaced an older one, both forms are shown, because most code you will read in the wild still uses the older one. You should also be willing to read a compiler error carefully, since in a declarative framework the type system carries a lot of the explanatory load.
By the end of the course you will be able to start an application from an empty Xcode template and build a real screen in it: a navigation stack over a list of data, rows that expand and collapse, a form that takes input and validates it, a sheet that presents and dismisses, a model that is owned in exactly one place and observed everywhere it is needed, asynchronous loading that cancels when the user leaves, transitions that make the change legible, an interface that responds correctly to VoiceOver, Dynamic Type and dark mode, and a UI test that proves the most important journey still works after you change something on Tuesday.
Approach:
The subject of this course is SwiftUI, but the skill it teaches is not the syntax of SwiftUI. Any syntax can be looked up in an afternoon. What cannot be looked up is the judgement that the syntax exists to support: how to decide where a piece of state should live, how to tell a state problem from a layout problem from a lifecycle problem when the symptom looks the same, and how to structure an interface so that the next person, including you in six months, can change it without fear. The teaching is therefore organised as a chain of dependencies rather than as a catalogue of features, and every stage produces something that can be run, previewed, or tested rather than something that merely has to be believed.
Steps:
- Start with the view system, because everything else is expressed in terms of it. Learn what a view is, how the framework rebuilds it, how the app and scene types fit together, how containers arrange their children, how modifiers compose, and how the preview canvas lets you see the result without a simulator. Introduce state here in its simplest form so that the concept is already familiar when the harder versions arrive.
- Then treat state as a question of ownership rather than a question of syntax. Work through the property wrappers one at a time, and for each one establish the same three facts: who creates it, who can read it, who can write it. Introduce the Observation framework and be explicit about what it changed and what it did not, so that older code stays readable and newer code stays simple.
- Follow the ownership rules into the parts of the topic that are harder to look up: how state survives or does not survive a change of view identity, how to keep the amount of stored state small, how to run asynchronous work that cancels itself when the view goes away, and how a navigation path can be driven from outside the application by a deep link.
- Build the interface with the tools the platform provides: navigation stacks and value-based links, lists and forms and sections, the standard controls with their bindings, and the three different mechanisms for presenting something on top, each matched to the gravity of the decision.
- Reach past the built-in containers, first to the Layout protocol for arrangements that the stacks do not cover, then to GeometryReader for the rare case that genuinely needs measurement, then to Canvas and TimelineView for drawing and continuous animation.
- Learn the two animation mechanisms separately, because they are not interchangeable, and then meet the transition effects that make a change legible rather than abrupt.
- Treat accessibility, Dynamic Type and dark mode as requirements rather than as polish, and finish with the tests, both the view-level tests that check structure and the user interface tests that check journeys.
- Throughout, work by breaking and repairing. Take each screen apart, ask where the state should have been, find the mistake, and fix it, because the intuition that comes from watching a rule fail is the part that survives the course.
Answer:
A working understanding of SwiftUI comes down to being able to answer four questions about any screen you meet. Where does the data on this screen live, and who owns it? Which of the values on this screen can change, and which of them are merely inputs? When the data changes, what exactly does the framework rebuild, and what does it leave alone? And how would a person who cannot see the screen, or who has enlarged the text, or who is outside in bright sunlight, be able to use it?
The first three questions are answered by the ownership rules and by the identity rules that govern when stored state is discarded. The fourth is answered by the accessibility and appearance APIs, and by the tests. A course on SwiftUI is therefore not really a course on SwiftUI at all; it is a course in making a declarative interface explain itself, and that is the part that keeps being useful long after the specific views have changed.
