swiftui-architecture
Installation
SKILL.md
Modern SwiftUI Architecture
Concise entry point for pure SwiftUI architecture without ViewModels. Use the references for patterns, examples, and edge cases.
Scope
This skill covers SwiftUI views and their data flow.
When a request asks you to restructure UIKit or AppKit code, say that this guidance does not cover that code. Leave its internals alone. Answer at the boundary instead:
- Wrap an existing view controller in
UIViewControllerRepresentableto show it in SwiftUI. - Wrap an existing view in
UIViewRepresentableonly when aUIViewis already separated from its controller. - Use
UIHostingControllerfor the opposite direction, to show a SwiftUI view inside UIKit. - On macOS, use
NSViewControllerRepresentable,NSViewRepresentable, andNSHostingControllerin the same three roles.
Keep the wrapped code's state where it already lives. Pass the SwiftUI side's values into the wrapper. Send the wrapper's events back out through a callback.