I'm using NSPersistentCloudKitContainer to sync CoreData+Cloudkit. I am basing my code on Apple's example in the code downloaded (see reference below). My Core Data root record is a hierarchy (list with children items on the list). I have assumed the root record CKShare is being shared - and not the zone (because the share has a hierarchy). However, after reading Apple forums, it seems there may be issues with NSPersistentCloudKitContainer and the answer appears to be to make a "deep copy".
The issue is that when a participant removes themselves from the shared list, or the owner stops the share, the share of course is removed BUT... the list is also deleted from Core Data. It would seem to me (like in the case of Apple's Notes, Reminders, Photos etc), that when a share is removed, the local data should persist (in Core Data).
COREDATA / CLOUDKIT SHARING CODE: (can be downloaded from Apple) Apple's documentation talks about making a "deep copy" before removing the share. (https://developer.apple.com/documentation/coredata/sharing_core_data_objects_between_icloud_users). But there is no further documentation than the mention.
How (and where) would one create a deep copy so that an owners Core Data entity persists after the share is deleted?