Greetings,
I'm developing a recipe app to learn SwiftUI. It persists the user's recipe data with Core Data, recently adding CloudKit support by switching the container type to NSPersistentClouKitContainer and adding history tracking and a merge policy. Upon installation the app instantiates a persistent store with a sizable set of recipe items from a bundled JSON file, which are eventually successfully synced to iCloud. Upon installing on a *second* simulator/device, though, the JSON-supplied data is eventually duplicated in the local persistent store when an iCloud sync happens, which takes about nine minutes to occur.
Two questions, then: I thought that by setting NSPersistentHistoryTrackingKey true and setting a merge policy of NSMergeByPropertyStoreTrumpMergePolicy, Core Data+Cloudkit would prevent such duplication by comparing attribute by attribute per record. The data from each installation are identical...do I have to handle duplication control manually? If so, what, then, is the point of having a merge policy?
Second, why does iCloud sync consistently take nine minutes to sync the cloud-based data to the local store on the second and subsequent installations? I'd skip using the JSON-based data if that sync happened in a minute or so. Changing the size of the cloud-based data by beginning with a smaller JSON file has no effect on how long sync takes to begin trickling in data.
I'm at a loss as to what the best practice is for instantiating and maintaining data on subsequent installations.
I'm developing a recipe app to learn SwiftUI. It persists the user's recipe data with Core Data, recently adding CloudKit support by switching the container type to NSPersistentClouKitContainer and adding history tracking and a merge policy. Upon installation the app instantiates a persistent store with a sizable set of recipe items from a bundled JSON file, which are eventually successfully synced to iCloud. Upon installing on a *second* simulator/device, though, the JSON-supplied data is eventually duplicated in the local persistent store when an iCloud sync happens, which takes about nine minutes to occur.
Two questions, then: I thought that by setting NSPersistentHistoryTrackingKey true and setting a merge policy of NSMergeByPropertyStoreTrumpMergePolicy, Core Data+Cloudkit would prevent such duplication by comparing attribute by attribute per record. The data from each installation are identical...do I have to handle duplication control manually? If so, what, then, is the point of having a merge policy?
Second, why does iCloud sync consistently take nine minutes to sync the cloud-based data to the local store on the second and subsequent installations? I'd skip using the JSON-based data if that sync happened in a minute or so. Changing the size of the cloud-based data by beginning with a smaller JSON file has no effect on how long sync takes to begin trickling in data.
I'm at a loss as to what the best practice is for instantiating and maintaining data on subsequent installations.