SwiftUI Apps Decouple View and Data layers

Hi, I'm playing around SwiftUI App code organization.

I've skimmed through the forum but found only one topic related to SwiftUI architecture.

Aspirations:

  • decouple View and Data layers and loosen dependencies between them
  • easily change a data source from web to file etc in different projects without changing any View implementation
  • easily change a data source format from JSON to XML etc.
  • share the same data source between different View presentations(Grid,Chart...)
  • maximize reusing code between different projects
  • testability
  • easily split the development of View and Data layers between independent developers

Experimenting I came to this code sketch: SwiftUI-MVVM-Concept

It's interesting to hear some thoughts may be your take on how to differently implement some parts to get it more resilient and flexible based on demands in your project.

if you have a link to some interesting concept applicable to SwiftUI apps, please share here

Different takes I came across:

Clean-architecture-swiftui
SwiftUI-Architectures
ModernMVVM

1 Like

Plug for the glaring omission of the composable architecture: GitHub - pointfreeco/swift-composable-architecture: A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.

2 Likes
1 Like

iOS-Clean-Architecture-MVVM
iOS-Modular-Architecture

Clean Architecture (MVVM + Combine + SwiftUI/UIKit)