RESEARCH ON THE PROBLEM OF MIGRATING MVVM ARCHITECTURE TO MODERN IOS APPLICATIONS BUILT WITH SWIFTUI

Authors

DOI:

https://doi.org/10.32782/IT/2024-2-20

Keywords:

SwiftUI architecture, MVC, MVVM, MV, iOS development

Abstract

Experienced software developers with many years of experience may unknowingly create additional complexity for themselves in a new environment by reusing their past experience in a new context when switching to a new technical stack. This works in many cases, but sometimes it can add unnecessary complexity to the project, which increases the amount of code and makes it difficult to maintain and extend. In projects built for the Apple ecosystem, everything is built around a library on which the application’s graphical interface will be built. The vast majority of developers in this ecosystem started their journey with frameworks created by Apple, such as UIKit or AppKit. Objective of the study. The article deals with the problem of using the MVVM architecture for applications whose interface is built on SwiftUI. The research is aimed at highlighting the use of ready-made solutions built into SwiftUI to take advantage of the benefits conceptually embedded in the MVVM architecture without using it. Also, the problem of often misunderstanding the area of responsibility of the Model layer was considered. Methodology. A theoretical analysis of several architectures that are widely used in building applications in the Apple ecosystem is carried out. For clarity, numerous examples are created to cover both simple and more complex cases. Scientific novelty. Apple has never focused on the application architecture in its WWDC educational materials on SwiftUI, but provided numerous examples of the use of new frameworks. To write this article, we have reviewed and analysed the available educational materials related to the chosen topic. The authors traced the cause-andeffect relationship of unnecessary code complexity when switching from UIKit/AppKit to SwiftUI due to the influence of the developer’s past experience. The term MV architecture was introduced, which is native to SwiftUI applications. Conclusions. As a result of the work, a number of arguments have been identified according to which the use of MVVM architecture in an application whose interface is built using SwiftUI is inappropriate and unnecessary. Also, a number of problems that arise when using this pattern and how to avoid them were outlined. Attention was focused on specific important details of implementing all application layers using MV architecture.

References

Fauzi Sholichin, Monh Adham Bin Isa, Shahliza Abd Halim, Muhammad Firdaus Bin Harun, Review of iOS Architectural pattern for testability, modifiability, and performance quality, 2019.

Robert Mejia, Declarative and Imperative Programming using SwiftUI and UIKit, 2019. URL: https://medium.com/@rmeji1/declarative-and-imperative-programming-using-swiftui-and-uikit-c91f1f104252

Apple Developer Documentation, SwiftUI. URL: https://developer.apple.com/documentation/swiftui/4. Baeldung, What is Pojo Class?, 2024. URL: https://www.baeldung.com/java-pojo-class

Apple Developer Documentation, Cocoa Core Competencies. URL: https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html

Estefanía García Gallardo, What is MVVM Architecture?, 2023. URL: https://builtin.com/softwareengineering-perspectives/mvvm-architecture

Apple Developer Documentation, Model data. URL: https://developer.apple.com/documentation/swiftui/model-data

Apple Developer Documentation, Managing model data in your app. URL: https://developer.apple.com/documentation/swiftui/managing-model-data-in-your-app

Chris Eidhof, Matt Gallagher, Florian Kugler, App Architecture: iOS Application Design Patterns in Swift, 2018.

Apple Developer Documentation, Migrating from the Observable Object protocol to the Observable macro. URL: https://developer.apple.com/documentation/swiftui/migrating-from-the-observable-objectprotocol-to-the-observable-macro

Apple Developer Documentation, ObservationIgnored. URL: https://developer.apple.com/documentation/Observation/ObservationIgnored()

Published

2024-07-31