I was wrong! MVVM is NOT a good choice for building SwiftUI applications

SwiftUI was introduced at WWDC 2019 and it completely changed how we build our apps for Apple platform. SwiftUI provided a declarative framework, which allowed developers to quickly and easily build user interface as compared to its predecessor UIKit or AppKit. Somewhere along the lines we adopted MVVM (Model View ViewModel) design pattern as the default pattern when building SwitUI applications. In this post, I will cover my experience of using MVVM pattern with SwiftUI framework and how it worked against the SwiftUI framework, making things more complicated.

Before I begin, I want to point out that I was the biggest advocate of the MVVM design pattern. I have written books on SwiftUI and MVVM, I created video courses, YouTube videos and even wrote dozens of articles explaining the benefits of using MVVM pattern for SwiftUI applications. If you are a developer and you jumped on the MVVM bandwagon then I was the driver.

You can read the complete article here: https://azamsharp.com/2022/07/17/2022-swiftui-and-mvvm.html

Post not yet marked as solved Up vote post of azamsharp Down vote post of azamsharp
2k views

Replies

I read your article well. I definitely agree if it's a simple app like your example.

However, it is not optimistic when it comes to having a slightly more complex function.

If a loading indicator is needed during a network call, who and how controls it?

If the service of domain A is completed, use the value to call the service of domain B and handle that data??

In simple cases like you said, there is no business logic between the View and the ViewModel, but more often than not.