Aleksa Simic
September 1, 2024
•
5 min read
For the past couple of months, there has been a big hype amongst the iOS community about the new MV (or how some people call it: State) pattern that should replace the MVVM in SwiftUI applications. Why? There are a couple of different reasons people advocating for MV say it's better than MVVM, but here are the two that are mentioned the most times:
Now, what's the idea behind MV pattern? The MV pattern can be broken down to two simple ideas:
The idea of MV is to simplify and speed up the development of iOS applications using SwiftUI
At some point at the beginning of this year, me and my team at Aetherius solutions had a chance to start working on a new iOS project from scratch, and the tech lead on the project decided that we should support minimum iOS version of 17.0, so we thought that trying out MV would be good choice because we could use @Observable macro which works great with "aggregate models" from MV.
At start, everything was going pretty nice and smooth. But as soon as the project started growing, since we were a team of 4 iOS engineers constantly contributing to the codebase, thing started going downhill.
There are a couple of main reasons why that happened:
And I could add at least a couple of more items to this list.
At that point, we figured out that MV pattern just doesn't work that well for iOS apps that should be scalable and maintained by a bigger iOS team, and that we should probably try reverting back to MVVM.
After the decision to revert the whole application back to MVVM, we had to make a detailed plan on how to do it and not lose too much time, or break anything in the app.
The migration plan was the following:
And that was pretty much it. Much easier than we expected. It took our 4 members iOS team about two weeks in total to do the whole migration without a single regression bug.
After that, when the codebase was back to MVVM, we started writing unit tests and just in general felt like we have more control over the whole project, while the development speed stayed the same.
I always like to try out new things, and if there is one thing I have learned over the past 7 years of being in iOS development, it is that you should always experiment and try out as many different things as you can.
Why? Because you can (almost) always revert things to how they were before and you will (almost always) learn something from that experiment.
And yeah, MVVM still rocks for SwiftUI, mostly when it comes to large iOS apps.
iOS engineers from all over the world found these e-books and project templates as the ultimate source of knowledge needed to build and scale their mobile apps