SwiftUI sample architecture
Source-backed, high-level architecture notes for Apple sample-code pages grouped in the SwiftUI folder.
- Catalog module label:
SwiftUI - Coverage: 32 / 32 sample pages documented
- Source policy: archive hashes and extracted-tree references are verified locally before analysis
Samples
| Sample | Platforms | High-level architecture | Documented patterns |
|---|---|---|---|
| Add rich graphics to your SwiftUI app | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain GradientBuilderApp → ContentView → GradientModelStore → SwiftUI APIs. |
Central store, Binding-based state propagation |
| Adopting drag and drop using SwiftUI | iOS, iPadOS, Mac Catalyst, macOS, visionOS | A Swift sample with the source-visible chain AdoptingDragAndDropInASwiftUIAppApp → ContentView → DataModel → SwiftUI APIs. |
Binding-based state propagation |
| Backyard Birds: Building an app with SwiftData and widgets | iOS, iPadOS, Mac Catalyst, macOS, watchOS | A Swift sample bundle with entry-bearing project variants Multiplatform, Watch, Widgets, each leading to SwiftUI APIs. |
Actor-isolated state |
| Bringing multiple windows to your SwiftUI app | macOS | A Swift sample with the source-visible chain BookClubApp → ArcView → NavigationModel → SeededRandomNumberGenerator → SwiftUI APIs. |
Factory, Publisher-backed observable state, Actor-isolated state |
| Bringing robust navigation structure to your SwiftUI app | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain NavigationCookbookApp → ContentView → DataModel → SwiftUI APIs. |
Binding-based state propagation |
| Building a document-based app using SwiftData | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample bundle with entry-bearing project variants End, Start, each leading to SwiftUI APIs. |
Binding-based state propagation, Publisher-backed observable state, Actor-isolated state |
| Building a document-based app with SwiftUI | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain WritingApp → AccessoryView → WritingAppDocument → SwiftUI APIs. |
Binding-based state propagation |
| Building a great Mac app with SwiftUI | macOS | A Swift sample bundle with entry-bearing project variants Session1, Session2, each leading to SwiftUI APIs. |
Central store, SwiftUI environment injection, Binding-based state propagation, Publisher-backed observable state |
| Building rich SwiftUI text experiences | iOS, iPadOS, Mac Catalyst | A Swift sample with the source-visible chain SampleRecipeEditorApp → RootView → AttributedStringModel → SwiftUI APIs. |
Binding-based state propagation, Actor-isolated state |
| Composing advanced graphics effects with SwiftUI | iOS, iPadOS, Mac Catalyst, macOS, visionOS | A Metal, Swift sample with the source-visible chain App → ContentView → SwiftUI APIs. |
— |
| Composing custom layouts with SwiftUI | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain CustomLayoutSampleApp → ContentView → Model → SwiftUI APIs. |
SwiftUI environment injection, Publisher-backed observable state |
| Controlling the timing and movements of your animations | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain PhaseAndKeyframeAnimationSampleApp → ContentView → SwiftUI APIs. |
— |
| Creating a tvOS media catalog app in SwiftUI | tvOS | A Swift sample with the source-visible chain TVCatalogApp → ContentView → SwiftUI APIs. |
— |
| Creating accessible views | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain AccessibilityExamples → ExamplesView → ColorModel → SwiftUI APIs. |
View-controller organization, Binding-based state propagation |
| Creating custom container views | iOS, iPadOS, Mac Catalyst | A Swift sample with the source-visible chain DisplayBoardContainerApp → ContentView → CardRandomGenerator → SwiftUI APIs. |
Actor-isolated state |
| Creating visual effects with SwiftUI | iOS, iPadOS, Mac Catalyst | A Metal, Swift sample with the source-visible chain CreateVisualEffectsDemoApp → AppearanceEffectRenderer → Coordinator → SwiftUI APIs. |
Delegate or data-source callbacks, Coordinator, Binding-based state propagation |
| Customizing window styles and state-restoration behavior in macOS | macOS | A Swift sample with the source-visible chain DestinationVideo → ContentView → Coordinator → EnvironmentStateHandler → SwiftUI APIs. |
Delegate or data-source callbacks, Coordinator, Actor-isolated state |
| Enhancing your app’s content with tab navigation | iOS, iPadOS, Mac Catalyst, macOS, tvOS, visionOS | A Swift sample with the source-visible chain DestinationVideo → ContentView → Coordinator → EnvironmentStateHandler → SwiftUI APIs. |
Delegate or data-source callbacks, Coordinator, Actor-isolated state |
| Focus Cookbook: Supporting and enhancing focus-driven interactions in your SwiftUI app | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain FocusCookbookApp → ContentView → DataModel → SwiftUI APIs. |
Binding-based state propagation |
| Food Truck: Building a SwiftUI multiplatform app | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample bundle with entry-bearing project variants App, Widgets, each leading to SwiftUI APIs. |
View-controller organization, Protocol-oriented abstraction, Delegate or data-source callbacks, Central store, SwiftUI environment injection, Binding-based state propagation |
| Landmarks: Applying a background extension effect | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain LandmarksApp → LandmarksSplitView → SwiftUI APIs. |
Delegate or data-source callbacks, Actor-isolated state |
| Landmarks: Building an app with Liquid Glass | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain LandmarksApp → LandmarksSplitView → SwiftUI APIs. |
Delegate or data-source callbacks, Actor-isolated state |
| Landmarks: Displaying custom activity badges | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain LandmarksApp → LandmarksSplitView → SwiftUI APIs. |
Delegate or data-source callbacks, Actor-isolated state |
| Landmarks: Extending horizontal scrolling under a sidebar or inspector | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain LandmarksApp → LandmarksSplitView → SwiftUI APIs. |
Delegate or data-source callbacks, Actor-isolated state |
| Landmarks: Refining the system provided Liquid Glass effect in toolbars | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain LandmarksApp → LandmarksSplitView → SwiftUI APIs. |
Delegate or data-source callbacks, Actor-isolated state |
| Loading and displaying a large data feed | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain EarthquakesApp → ContentView → QuakesProvider → SwiftUI APIs. |
Binding-based state propagation, Actor-isolated state |
| Making a card game with drag, drop, and reordering in SwiftUI | macOS | A Swift sample with the source-visible chain SwiftUIReorderableApp → ContentView → SwiftUI APIs. |
— |
| Managing model data in your app | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain BookReaderApp → LibraryView → SwiftUI APIs. |
— |
| Migrating from the Observable Object protocol to the Observable macro | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain BookReaderApp → LibraryView → SwiftUI APIs. |
— |
| Monitoring data changes in your app | iOS, iPadOS, Mac Catalyst, macOS | A Swift sample with the source-visible chain BookReaderApp → LibraryView → SwiftUI APIs. |
SwiftUI environment injection, Publisher-backed observable state |
| Restoring your app’s state with SwiftUI | iOS, iPadOS, Mac Catalyst | A Swift sample with the source-visible chain StateRestorationApp → ContentView → ProductsModel → SwiftUI APIs. |
SwiftUI environment injection, Binding-based state propagation, Publisher-backed observable state |
| Wishlist: Planning travel in a SwiftUI app | iOS, iPadOS, Mac Catalyst | A Swift sample bundle with entry-bearing project variants WithSwiftData, WithoutPersistence, each leading to SwiftUI APIs. |
Delegate or data-source callbacks, Binding-based state propagation |
Cross-sample signals
Recurring documented patterns
| Pattern label | Sample documents |
|---|---|
| Binding-based state propagation | 14 |
| Actor-isolated state | 13 |
| Delegate or data-source callbacks | 10 |
| Publisher-backed observable state | 6 |
| SwiftUI environment injection | 5 |
| Central store | 3 |
| Coordinator | 3 |
| View-controller organization | 2 |
Type-role naming evidence
Counts below are declaration-name suffixes, not inferred patterns.
| Role suffix | Distinct declarations across samples |
|---|---|
View |
328 |
App |
30 |
Model |
20 |
Generator |
6 |
Controller |
6 |
Coordinator |
5 |
Provider |
4 |
Store |
3 |
Renderer |
2 |
Delegate |
2 |
Handler |
2 |
Observer |
2 |
Factory |
1 |
Document |
1 |
Manager |
1 |
DataSource |
1 |
Swift access-control evidence
These are declaration occurrences in scanned Swift source, including implicit internal declarations.
| Access level | Occurrences |
|---|---|
implicit internal |
7229 |
private |
1289 |
public |
513 |
private(set) |
41 |
fileprivate |
19 |
internal |
5 |
References
Generated from the verified local catalog and completed Markdown documents.