What’s new in core data?
Generated on 7/30/2024
1 search

This post is brought to you by Tailscan,
the best devtool for Tailwind CSS.
What's New in Core Data?
At WWDC 2024, Apple introduced several new features and enhancements related to Core Data, primarily through the new Swift Data framework. Here are the key updates:
-
Integration with Swift Data:
- Swift Data now uses Core Data by default to store information, making it easier to work with your queries while iterating on views. This integration allows for a more seamless experience when working with data in Swift.
-
Custom Data Stores:
- You can now adopt custom data stores in Swift Data, allowing you to store data using alternative backends like SQLite, remote web services, or even JSON files. This flexibility opens up a wide range of possibilities for data storage and management.
-
History API:
- Swift Data introduces a new history API that tracks changes to your app's models. This is particularly useful for tracking local changes that need to be synced to a remote web service. The history API also supports custom data stores, enabling comprehensive change tracking across different storage backends.
-
Index and Unique Constraints:
- The new index macro makes queries more efficient by optimizing how properties are stored and retrieved. The unique macro ensures that a set of properties have no duplicate entries, which helps in maintaining data integrity and improving query performance.
-
Schema Customization:
- Swift Data allows for schema customization using macros. For example, the schema macro helps avoid duplicate models, and the attribute macro can be used to preserve values on deletion, which is useful when working with the history API.
For a detailed overview of these features, you can refer to the following sessions:
- Platforms State of the Union (40:60)
- What’s new in SwiftData (03:34)
- Create a custom data store with SwiftData (13:00)
- Track model changes with SwiftData history (16:20)
Relevant Sessions
- Platforms State of the Union
- What’s new in SwiftData
- Create a custom data store with SwiftData
- Track model changes with SwiftData history
These sessions provide a comprehensive look at the new capabilities and improvements in Core Data through the Swift Data framework.

Create a custom data store with SwiftData
Combine the power of SwiftData’s expressive, declarative modeling API with your own persistence backend. Learn how to build a custom data store and explore how to progressively add persistence features in your app. To get the most out of this session, watch “Meet SwiftData” and “Model your schema with SwiftData” from WWDC23.

What’s new in SwiftData
SwiftData makes it easy to add persistence to your app with its expressive, declarative API. Learn about refinements to SwiftData, including compound uniqueness constraints, faster queries with #Index, queries in Xcode previews, and rich predicate expressions. Join us to explore how you can use all of these features to express richer models and improve performance in your app. To discover how to build a custom data store or use the history API in SwiftData, watch “Create a custom data store with SwiftData” and “Track model changes with SwiftData history”.

Track model changes with SwiftData history
Reveal the history of your model’s changes with SwiftData! Use the history API to understand when data store changes occurred, and learn how to use this information to build features like remote server sync and out-of-process change handing in your app. We’ll also cover how you can build support for the history API into a custom data store.

Platforms State of the Union
Discover the newest advancements on Apple platforms.