What's new in swift data

Asked on 06/12/2025

1 search

SwiftData has introduced several new features and improvements, as highlighted in the WWDC sessions:

  1. Schema Macros: SwiftData now includes a new schema macro to help avoid duplicate models. This is part of the framework's effort to make data modeling more efficient and safe by leveraging modern Swift language features like macros.

  2. Model Containers: There are new ways to set up and configure model containers, which are crucial for managing how data is stored and accessed within an app.

  3. Query Optimization: SwiftData has introduced complex filters and a new macro to optimize query performance, making data retrieval faster and more efficient.

  4. Custom Data Stores: SwiftData now supports custom data stores, allowing developers to use alternative backends like SQLite, remote web services, or JSON files. This flexibility is enhanced by the new datastore protocol, which supports any persistence backend.

  5. History API: The new SwiftData history feature allows apps to track modifications to their data, which is useful for syncing with servers or responding to changes from app extensions.

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

  7. Indexing and Unique Constraints: The addition of index and unique constraints helps make queries more efficient and ensures data integrity by preventing duplicate entries.

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:01:52).