Whats New about SwiftData?

Asked on 06/15/2025

1 search

In the "What's new in SwiftData" session at WWDC 2024, several new features and improvements were introduced for SwiftData. Here are the key updates:

  1. Schema Macro: A new schema macro helps avoid duplicate models, making it easier to manage your data models efficiently.

  2. Model Containers: There are new ways to set up and configure model containers, which are crucial for managing your app's data models.

  3. Query Optimization: You can now optimize queries with complex filters and use a new macro to improve performance.

  4. Index Macro: The introduction of the index macro allows you to make queries more performant by specifying which properties are commonly queried together.

  5. Unique Constraints: You can add unique constraints to your schema to prevent duplicate entries and enhance query performance.

  6. History API: A new history API is available to track changes to your app's models, which is useful for features like syncing with a server.

  7. Custom Data Stores: SwiftData now supports custom data stores, allowing you to use different persistence backends beyond the default CoreData.

For more detailed information, you can watch the session What’s new in SwiftData.