Why does a participant of a share not have a record referenced by the root record?

I am able to share a record in CloudKit using the instructions in the Apple Documentation, including the CloudKitShare sample, but when another user accepts the share, only the root record is saved in the sharedDatabase. There is supposed to be another record that has a reference to the root record.

I'm not sure what code to include in this post. Perhaps someone can tell me that much or know of a common programmer mistake that causes this error.

Here is the basic code, after I have removed code not essential to the problem, to make my code easier to read.

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata) {

        let container = CKContainer(identifier: cloudKitShareMetadata.containerIdentifier)

        let acceptSharesOperation = CKAcceptSharesOperation(shareMetadatas: [cloudKitShareMetadata])

        container.add(acceptSharesOperation)

    }

}

Did you set the parent in the child record?

The accept shares operation looks correct, so the issue may be in how you're defining the relationships between the root record and the child records you expect to be a part of the share. CloudKit uses the parent property to infer record hierarchies, not custom reference fields, so check that the other record you expect to be shared along with the root record has its parent property correctly set to the root record reference. The reference must also use CKRecord.ReferenceAction.none action — this is documented here.

Why does a participant of a share not have a record referenced by the root record?
 
 
Q