How do I resolve conflicts with SwiftData?

SwiftData includes support for CloudKit sync. However, I don't see any way to add conflict resolution behavior. For example, if different devices set different values for a field, or if a relationship is orphaned because of a deletion on another device, the application has to handle this somehow.

In Core Data (which SwiftData wraps), you can handle this with the conflict resolution system (docs) and classes like NSMergePolicy.

Is any of this accessible in SwiftData? If not, how do you deal with conflicts when syncing a SwiftData model with the cloud?

SwiftData doesn't allow the client to customize its conflict resolution semantics with the server. You can file an enhancement request for that though with some details about your use case and what you want to change.

How do I resolve conflicts with SwiftData?
 
 
Q