Core Data+CloudKit causing duplication after second device app install

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.
Never mind...I read Consuming Relevant Store Changes in Apple docs and downloaded the sample project Synchronizing a Local Store to the Cloud from 2019. The needed deduplication code is explained and shown in the former and executed in the latter. Beware: there is a code error in the sample project. You want to register for remote change notifications fired by the container.persistentStoreCoordinator, not the container itself.
I have similar situation. Upon new APP installation I populate Local Store from SQLLITE file (previously loaded from JSON). After some time those "reference" data duplicate.
As I understand you need to track all attempts to update local store and make sure you are not creating duplicates, correct ? Annoying :)
Core Data+CloudKit causing duplication after second device app install
 
 
Q