


Protocol Oriented View Architecture for Modern SwiftUI applications (Part 2)
Hello, in my previous post https://www.reddit.com/r/SwiftUI/comments/1tfn2jz/protocol_oriented_view_architecture_for_modern/ I discussed the Protocol Oriented Views for SwiftUI apps which has advantage of nil-safety, observing SwiftData queries and almost zero boilerplate.
I prepared an example (I'll add unit tests in part 3)
Please check it out
https://github.com/nusov/SwiftUI-POV-Architecture/tree/main/Breakthrough
In this example, I didn't create a separate protocol for models; it is highly simplified, but it conveys the main idea.
- App State (Global Observable, for future use, inject once in the RootView access everywhere)
- App Repository (Controls main data cycle seed/reset)
- App Settings (Persistent settings, I used AppStorage but you can use any library or plain UserDefaults)
- ModelContainer with factories for live app and #Previews
- AppSchema
- UI and some binding using POV architecture
- Everything is Observable, thanks for comments in the previous post I fixed some flawsю
Feedback is highly appreciated