Post

Replies

Boosts

Views

Activity

Reply to Invalid Bundle ID for container
I found a solution for my case, so I'm posting to help anyone else with a similar setup. If you're sharing a CloudKit container across multiple apps (using different bundle IDs), apart from specifying the container identifier when initializing the container, you must set NSPersistentCloudKitcontainerOptions on the NSPersistentCloudKit container (this is in the AppDelegate if you selected the "Use CloudKit" option during project creation) as shown below: let container = NSPersistentCloudKitContainer(name: "ModelName") guard let description = container.persistentStoreDescriptions.first else { 		 fatalError("No container descriptions available") } description.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier:"iCloud.com.organization.ContainerName") container.persistentStoreDescriptions = [ description ] In your code, when you access the desired container, you use the same container ID as in the description above: let container = CKContainer(identifier: "iCloud.com.organization.ContainerName") You can use this method to specify and access multiple containers as well. I found my solution in the WWDC 19 talk: https://developer.apple.com/videos/play/wwdc2019/202/
Nov ’20