Swift Data updates

Asked on 06/11/2025

1 search

At WWDC 2024, several updates and new features were introduced for Swift Data. Here are some of the key updates:

  1. Schema Macros: A new schema macro was introduced to help avoid duplicate models. This allows for more efficient data modeling and persistence across app launches.

  2. Model Containers: There are new ways to set up and configure model containers, allowing for more customization in how data is stored and managed.

  3. Custom Data Stores: Swift Data now supports fully custom data stores, enabling developers to use alternative backends like SQLite, remote web services, or JSON files. This flexibility allows the use of Swift Data's API with various storage formats.

  4. Index and Unique Macros: The addition of index and unique macros helps optimize queries by making them more efficient and ensuring no duplicate entries in a set of properties.

  5. History API: Swift Data now includes a history API that tracks changes in the data store, making it easier to manage data changes over time and synchronize with remote services.

  6. Class Inheritance: New in iOS 26, Swift Data supports class inheritance, allowing developers to build model graphs that harness inheritance, which is useful for models that form a natural hierarchy.

For more detailed information, you can refer to the session What’s new in SwiftData (00:00:07) and SwiftData: Dive into inheritance and schema migration (00:02:11).