Apple's modern declarative UI framework — one DSL targets iPhone, iPad, Mac, Apple Watch, Apple TV, and Vision Pro. The future of building anything on Apple platforms.
← Back to Client Side@State, @Binding, @Environment, and @Observable..padding(), .foregroundColor() — a small set composes endlessly.import SwiftUI @Observable class ProductStore { var products: [Product] = [] var isLoading = true func load() async { let (data, _) = try! await URLSession.shared.data(from: API.products) products = try! JSONDecoder().decode([Product].self, from: data) isLoading = false } } struct ProductListView: View { @State private var store = ProductStore() var body: some View { NavigationStack { List(store.products) { p in Text("\(p.name) — $\(p.price)") } .overlay { if store.isLoading { ProgressView() } } .task { await store.load() } .navigationTitle("Products") } } }
@State — local view state.@Binding — two-way binding to parent state.@Observable + @State — modern reference-type stores (replaces @StateObject/@ObservedObject).@Environment — read shared values (locale, color scheme, dismiss action).SwiftUI uses a preference-based layout — parents propose sizes, children respond. Stacks (HStack, VStack, ZStack), Grid, and the Layout protocol cover everything from forms to complex custom geometries.
Wrap state changes in withAnimation { ... } and SwiftUI interpolates the difference. Built-in transitions, matched geometry effects, and the new PhaseAnimator / KeyframeAnimator APIs cover most needs without third-party libraries.
SwiftUI integrates with Swift's async/await via .task { }, which auto-cancels when the view disappears. @MainActor ensures UI updates land on the right thread.
UIViewRepresentable / NSViewRepresentable bridges existing UIKit / AppKit views into SwiftUI — and the reverse with UIHostingController. Most apps still mix the two for a few years to come.
| Tool | Purpose |
|---|---|
| SwiftData | Apple's modern persistence layer (replaces Core Data for new apps). |
| The Composable Architecture (TCA) | Popular state-management library (Redux-inspired). |
| Swift Charts | Native data viz framework. |
| StoreKit 2 | In-app purchases & subscriptions. |
| WidgetKit / App Intents | Home-screen widgets & Siri integration. |
The default for any new Apple app — Apple's own first-party apps adopt it.
SwiftUI is essentially required on these platforms.
Mac apps that look and feel right at home.
Lock-screen widgets, Live Activities, Siri shortcuts.