what's new on swiftdata

Asked on 06/13/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 highlights:

  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 enhance how data is managed and accessed within your app.

  3. Query Optimization: The session covers how to optimize queries with complex filters and introduces a new macro to improve performance.

  4. Custom Data Stores: SwiftData now supports custom data stores, allowing you to use alternative backends like SQLite, a remote web service, or JSON files. This flexibility is a significant enhancement for developers needing custom storage solutions.

  5. History API: SwiftData history is a new feature that lets your app track modifications to its data, which is useful for syncing with servers or responding to changes from app extensions.

  6. Index and Unique Constraints: The addition of index and unique constraints makes queries more efficient and ensures data integrity by preventing duplicate entries.

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