Adopting SwiftData: A Simplified Approach to Persistence in Native iOS Application
Diwan, Gagan (2024)
Diwan, Gagan
2024
All rights reserved. This publication is copyrighted. You may download, display and print it for Your own personal use. Commercial use is prohibited.
Julkaisun pysyvä osoite on
https://urn.fi/URN:NBN:fi:amk-202405079836
https://urn.fi/URN:NBN:fi:amk-202405079836
Tiivistelmä
iOS development is ever evolving and has kept pace with recent shift towards declarative programming practices by introducing new frameworks such as SwiftUI and SwiftData that enables persistence using declarative code.
This thesis explores the seamless integration of SwiftData, a persistent framework, with SwiftUI applications. By leveraging Swift's native types for data modeling, SwiftData bridges the gap between code and data definition.
The adoption process involves five steps: building models, importing SwiftData & annotating model class, defining relationships and property attributes, setting model container and finally, accessing model context object to work with data.
The adoption process is explored through three demo applications. A book application demonstrates one-to-one relationships and core SwiftData adoption steps. A messaging application showcases one-to-many relationships, while a learning diary application discusses many-to-many relationships and the final adoption step. Additionally, the thesis explores CRUD operations (Create, Read, Update, Delete) alongside filtering, sorting, searching, and migration strategies.
While SwiftData offers tight SwiftUI integration and features like automatic lightweight migrations and custom migration support, the framework is still under development. The current limitations include compatibility only with iOS 17 onwards and a smaller API compared to Core Data. However, SwiftData's potential for the future is promising as it continues to evolve.
This thesis concludes that a detailed evaluation of SwiftData's functionality based on specific application needs is recommended before adopting it for new projects. Further research opportunities include a comparative study between SwiftData and Core Data and exploring SwiftData in networking environment for real-world application implementation. These investigations will solidify SwiftData's position as a powerful tool for building persistent enabled SwiftUI applications.
This thesis explores the seamless integration of SwiftData, a persistent framework, with SwiftUI applications. By leveraging Swift's native types for data modeling, SwiftData bridges the gap between code and data definition.
The adoption process involves five steps: building models, importing SwiftData & annotating model class, defining relationships and property attributes, setting model container and finally, accessing model context object to work with data.
The adoption process is explored through three demo applications. A book application demonstrates one-to-one relationships and core SwiftData adoption steps. A messaging application showcases one-to-many relationships, while a learning diary application discusses many-to-many relationships and the final adoption step. Additionally, the thesis explores CRUD operations (Create, Read, Update, Delete) alongside filtering, sorting, searching, and migration strategies.
While SwiftData offers tight SwiftUI integration and features like automatic lightweight migrations and custom migration support, the framework is still under development. The current limitations include compatibility only with iOS 17 onwards and a smaller API compared to Core Data. However, SwiftData's potential for the future is promising as it continues to evolve.
This thesis concludes that a detailed evaluation of SwiftData's functionality based on specific application needs is recommended before adopting it for new projects. Further research opportunities include a comparative study between SwiftData and Core Data and exploring SwiftData in networking environment for real-world application implementation. These investigations will solidify SwiftData's position as a powerful tool for building persistent enabled SwiftUI applications.