Why my iOS team switched to Clean Architecture

#ios#clean#architecture
Last updated . Originally published

Moving to Clean Architecture helps our team resolve with collaboration problems and increase the quality of our codebase, but add more code boilerplate and complexity. In this post, I will discuss my team architecture’s problems, the solution, and the results after switching to Clean Architecture. If you are not familiar with Clean Architecture, I recommend you to read The Clean Architecture.

Our Problem#

Before switching to Clean Architecture, we mainly used VIPER architecture. VIPER is a well-known architecture in the iOS community, and many companies have widely adopted it.

However, when working more closely with the Android or the Flutter teams, we noticed that VIPER uses different terminologies that would need to be clarified for developers outside the iOS team. While the iOS members are all good with VIPER, our teams are now rotating members between the iOS, Android, and Flutter teams. Consequently, without vital architecture standardization on all mobile platforms, it could be more challenging for the team to understand each other’s codebase.

Our Solution#

After some discussions and research, our team decided to switch to Clean Architecture with MVVM. Google’s Guide to App Architecture mainly inspired the approach of our Clean Architecture and MVVM implementation. The App Architecture guide is well-documented, widespread, and designed for Android mobile projects.

Why Clean Architecture?#

When comparing and looking deep into Clean Architecture as well as VIPER, we found that:

Our Results#

Most importantly, we have successfully switched to Clean Architecture with MVVM and are applying it to all new projects. The team is now more aligned with the architecture, and collaboration between iOS, Android, and Flutter developers has significantly improved. For instance, our mobile developers can now discuss UseCase, Repository, Domain Layer, or Data Layer while developing features. It also brings opportunities for developers to do code reviews for other platforms.

Regarding resources, we created a document showing how to implement the Clean Architecture with MVVM in iOS. In detail, we have different sections based on the layers (Presentation, Domain, Data) that explain and show code examples for developers.

"The detail of the iOS application architecture"

We also applied Clean Architecture and MVVM to our iOS templates. The template will help developers start a new project with our preferred architecture by just pressing the "Use this template" button.

If you are considering switching to Clean Architecture, you might need to discuss it with your team and evaluate its benefits and drawbacks. It is essential to understand that Clean Architecture is not a silver bullet and might not fit all projects. However, it is worth considering if you are looking for a standard architecture across all mobile platforms.

Thanks for reading! If you have any questions or comments, please mention me on X or Linkedin with this post.