Previews and Package Oriented Programming
summary
Demonstrates concrete patterns: use NavigationStack previews to show toolbars, put UI state in small pieces and pass it with dot-constant binding or real @Binding, and treat previews like lightweight API tests. Builds a demo app split into local Swift packages (basic types, helper views, journey model, UI packages) with explicit public inits, static example data for previews, and a data source as an ObservableObject with private @Published storage. Notes tradeoffs: previews can break builds, packages can’t be declared iOS‑only, and SwiftPM rebuild behavior is usually incremental (command‑line builds can be faster).
AI-written summary · about
chapters (8)
- 0:00Swift UI value vs reference
- 4:08Fixing SwiftUI previews
- 7:32Separating view and state
- 13:33Modularizing Swift code
- 17:37Creating local packages
- 25:23Building the UI with modules
- 31:07Advanced modularization tips
- 38:07Q&A and closing remarks
related talks
17mMastering SwiftUI Previews: How the Project Structure can hel
11mKeynote Preview - Interview With
27mCode organization strategies for complex globalization in Swift
29mWarm Up
20mSpeeding up UIKit-based app development with Xcode Previews
46mSqueezing Even More Out of SwiftUI Preview
18mBuckets of Code
26mKeeping Things Modular With Swift Package Manager
