Does swift data supports deduplication with iCloud sync?

Asked on 03/29/2025

1 search

Yes, Swift Data supports deduplication with iCloud sync through the use of a new schema macro that allows you to construct a compound constraint on persistent models. You can use the unique macro to specify which combinations of your model's properties must remain unique. When two model instances share the same unique values, Swift Data will perform an upsert on collision with an existing model, effectively avoiding duplicates. This feature is part of the enhancements introduced in Swift Data, as discussed in the session What’s new in SwiftData.