I'm moving away from UIKit's MVC and I'm torn between standard MVVM and The Composable Architecture (TCA). MVVM feels native but can get messy with complex state, whereas TCA seems very structured but has a steep learning curve. For a team of five developers, which architecture provides the best balance of testability and development speed for a long-term Swift project?
3 answers
MVVM is the "path of least resistance" for SwiftUI because it aligns with how Apple designed the framework. However, as the app grows, ViewModels tend to become "Massive ViewModels." If your project is highly complex with many side effects and shared states, TCA is superior for testability. Everything in TCA is a pure function, which makes unit testing a breeze. We adopted TCA for our e-commerce app in late 2024, and while it took a month for everyone to "get it," we now have nearly 95% code coverage and significantly fewer state-related bugs compared to our old MVVM implementation.
Does TCA’s heavy use of "Boilerplate" code ever slow down your ability to push out small UI changes or hotfixes compared to a simpler MVVM setup?
If you go with MVVM, make sure to use "Container Views" to keep your ViewModels small. Don't let one ViewModel handle an entire screen of logic.
Modularizing ViewModels is key. We follow the rule of "one ViewModel per logical feature," which keeps things manageable even in a standard MVVM setup.
Gregory, that’s the main trade-off. For a simple "change the button color" fix, TCA is slower because you have to touch the Action, Reducer, and State. But for "fix this weird bug where the cart doesn't update when the user logs out," TCA is 10 times faster to debug. In MVVM, you might be hunting through three different ViewModels to find where the state went wrong. In TCA, you just look at the unified Store. It’s an investment in stability over raw "feature-cranking" speed.