SwiftUI is Apple's declarative framework for building user interfaces across iOS, iPadOS, macOS, watchOS, and tvOS, introduced in 2019. Unlike imperative UIKit, SwiftUI describes what the UI should look like at any given state, and the framework handles the rendering and updates automatically. It uses a reactive data flow model where UI components automatically update when underlying data changes, eliminating manual view controller management. The key mental model: views are cheap, ephemeral structs that SwiftUI recreates frequently—state lives elsewhere (in property wrappers like @State or @Observable models), and SwiftUI diffs the view tree to render only what changed. iOS 26 (WWDC25) introduced Liquid Glass, WebView, rich-text editing in TextEditor, and the @Animatable macro—master property wrappers and the Observation framework and you've mastered 80% of SwiftUI.
What This Cheat Sheet Covers
This topic spans 27 focused tables and 206 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core Property Wrappers
Property wrappers are the backbone of SwiftUI's reactive data model. Choosing the right wrapper—@State vs @StateObject vs @Observable—determines ownership, lifetime, and when views re-render.
| Wrapper | Example | Description |
|---|---|---|
private var count = 0 | • View-owned mutable state for simple value types • SwiftUI rerenders when value changes | |
var isOn: Bool | Two-way connection to a parent's @State—changes propagate both up and down the hierarchy. | |
var vm = ViewModel() | View-owned reference type conforming to ObservableObject—survives view recreation and owns the object's lifetime. | |
var vm: ViewModel | Externally-owned reference type—does not own the object, receives it from parent or environment. | |
var settings: Settings | Dependency injection for shared objects passed down the hierarchy, skipping intermediate views. | |
@Observable class Model { var name = "" } | • Modern macro-based observation—no @Published needed• views auto-track only accessed properties |