how to avoid duplicated data, syncing with icloud kit and swiftdata, ios17+
Generated on 3/9/2025
1 search
To avoid duplicated data when syncing with iCloud using SwiftData in iOS 17 and later, you can utilize the new schema macro features introduced in SwiftData. Specifically, the unique macro allows you to define which combinations of your model's properties must remain unique. This ensures that when two model instances share the same unique values, SwiftData will perform an upsert on collision with an existing model, effectively preventing duplicates.
For example, in a hypothetical Trips app, you can use the unique macro to ensure trips are unique across their name, start date, and end date. This allows the app to have multiple trips with the same name, but only if they have different start or end dates. This approach makes it easy to avoid duplicates in the data, as SwiftData can reason about which models represent duplicates and perform updates to the data instead.
For more details, you can refer to the session What’s new in SwiftData (02:43) where the unique macro is discussed.

Meet FinanceKit
Learn how FinanceKit lets your financial management apps seamlessly and securely share on-device data from Apple Cash, Apple Card, and more, with user consent and control. Find out how to request one-time and ongoing access to accounts, transactions, and balances — and how to build great experiences for iOS and iPadOS.

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.

Port advanced games to Apple platforms
Discover how simple it can be to reach players on Apple platforms worldwide. We’ll show you how to evaluate your Windows executable on Apple silicon, start your game port with code samples, convert your shader code to Metal, and bring your game to Mac, iPhone, and iPad. Explore enhanced Metal tools that understand HLSL shaders to validate, debug, and profile your ported shaders on Metal.

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

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.

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”.

Customize feature discovery with TipKit
Focused on feature discovery, the TipKit framework makes it easy to display tips in your app. Now you can group tips so features are discovered in the ideal order, make tips reusable with custom tip identifiers, match the look and feel to your app, and sync tips using CloudKit. Learn how you can use the latest advances in TipKit to help people discover everything your app has to offer.