ios – Getting “Invalid bundle ID for container” error when using NSPersistentCloudKitContainer

[ad_1]

I have a workable CoreData app (local storage)

I would like to make it workable with iCloudKit.

After migrate from NSPersistentContainer to NSPersistentCloudKitContainer (https://github.com/yccheok/xxx/blob/main/xxx/CoreDataStack.swift#L21) , I was hoping I can achieve success in the following testing.

  1. Launch the app
  2. Write a CoreData record for the first time.
  3. Hopefully the data will then quietly sync to iCloud from device.
  4. Delete the app
  5. Install and launch the app again
  6. Hopefully the old data before uninstall will quietly sync from iCloud to device.
  7. Able read the old data before uninstall

However, I get stuck in step 2. After several attempts, I am still getting the following iCloud related error.


Here’s the complete error log.

CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](36): Validating options: <NSCloudKitMirroringDelegateOptions: 0x600001c0d050> containerIdentifier:iCloud.com.yocto.xxx databaseScope:Private ckAssetThresholdBytes:<null> operationMemoryThresholdBytes:<null> useEncryptedStorage:NO useDeviceToDeviceEncryption:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName:<null> containerProvider:<PFCloudKitContainerProvider: 0x600002c08770> storeMonitorProvider:<PFCloudKitStoreMonitorProvider: 0x600002c08730> metricsClient:<PFCloudKitMetricsClient: 0x600002c087d0> metadataPurger:<PFCloudKitMetadataPurger: 0x600002c08790> scheduler:<null> notificationListener:<null> containerOptions:<null> defaultOperationConfiguration:<null> progressProvider:<NSPersistentCloudKitContainer: 0x600003b00b00> test_useLegacySavePolicy:YES archivingUtilities:<PFCloudKitArchivingUtilities: 0x600002c08800>
storeOptions: {
    NSInferMappingModelAutomaticallyOption = 1;
    NSMigratePersistentStoresAutomaticallyOption = 1;
    NSPersistentCloudKitContainerOptionsKey = "<NSPersistentCloudKitContainerOptions: 0x60000204f0f0>";
    NSPersistentHistoryTrackingKey = 1;
    NSPersistentStoreMirroringOptionsKey =     {
        NSPersistentStoreMirroringDelegateOptionKey = "<NSCloudKitMirroringDelegate: 0x600001504a90>";
    };
}
CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate observeChangesForStore:inPersistentStoreCoordinator:](385): <NSCloudKitMirroringDelegate: 0x600001504a90>: Observing store: <NSSQLCore: 0x131e151a0> (URL: file:///Users/yccheok/Library/Developer/CoreSimulator/Devices/F1F59F93-1800-4D43-AAE7-FD942D440B10/data/Containers/Data/Application/54000F75-F12A-4FF2-A2A1-545ACE41A367/Library/Application%20Support/xxx.sqlite)
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _setUpCloudKitIntegration](530): <NSCloudKitMirroringDelegate: 0x600001504a90>: Successfully enqueued setup request.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest](2928): <NSCloudKitMirroringDelegate: 0x600001504a90>: Checking for pending requests.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(2941): <NSCloudKitMirroringDelegate: 0x600001504a90>: Executing: <NSCloudKitMirroringDelegateSetupRequest: 0x600003b51180> 428D83F5-B1E4-4BC6-B411-A9D0583983F0
success write Optional("title 0"), Optional("body 0")
2022-04-10 21:40:58.519262+0800 xxx[2918:70575] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(1106): <NSCloudKitMirroringDelegate: 0x600001504a90>: Failed to set up CloudKit integration for store: <NSSQLCore: 0x131e151a0> (URL: file:///Users/yccheok/Library/Developer/CoreSimulator/Devices/F1F59F93-1800-4D43-AAE7-FD942D440B10/data/Containers/Data/Application/54000F75-F12A-4FF2-A2A1-545ACE41A367/Library/Application%20Support/xxx.sqlite)
<CKError 0x6000020516e0: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx"; partial errors: {
    com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2>
}>
CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(1106): <NSCloudKitMirroringDelegate: 0x600001504a90>: Failed to set up CloudKit integration for store: <NSSQLCore: 0x131e151a0> (URL: file:///Users/yccheok/Library/Developer/CoreSimulator/Devices/F1F59F93-1800-4D43-AAE7-FD942D440B10/data/Containers/Data/Application/54000F75-F12A-4FF2-A2A1-545ACE41A367/Library/Application%20Support/xxx.sqlite)
<CKError 0x6000020516e0: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx"; partial errors: {
    com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2>
}>
2022-04-10 21:40:58.519485+0800 xxx[2918:70575] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate recoverFromError:](2115): <NSCloudKitMirroringDelegate: 0x600001504a90> - Attempting recovery from error: <CKError 0x6000020516e0: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx"; partial errors: {
    com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2>
}>
CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate recoverFromError:](2115): <NSCloudKitMirroringDelegate: 0x600001504a90> - Attempting recovery from error: <CKError 0x6000020516e0: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx"; partial errors: {
    com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2>
}>
2022-04-10 21:40:58.528209+0800 xxx[2918:70575] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _recoverFromPartialError:forStore:inMonitor:]_block_invoke(2464): <NSCloudKitMirroringDelegate: 0x600001504a90>: Found unknown error as part of a partial failure: <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx">
CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _recoverFromPartialError:forStore:inMonitor:]_block_invoke(2464): <NSCloudKitMirroringDelegate: 0x600001504a90>: Found unknown error as part of a partial failure: <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx">
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _finishedRequest:withResult:](2959): Finished request: <NSCloudKitMirroringDelegateSetupRequest: 0x600003b51180> 428D83F5-B1E4-4BC6-B411-A9D0583983F0 with result: <NSCloudKitMirroringResult: 0x600002e6db00> success: 0 madeChanges: 0 error: <CKError 0x6000020516e0: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2; container ID = "iCloud.com.yocto.xxx"; partial errors: {
    com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x600002051b60: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 94EEBD82778D22EC; uuid = 340ED591-A422-4E70-8BC1-EC300A8C34C2>
}>
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest](2928): <NSCloudKitMirroringDelegate: 0x600001504a90>: Checking for pending requests.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(2944): <NSCloudKitMirroringDelegate: 0x600001504a90>: No more requests to execute.

The following error draws my attention

Invalid bundle ID for container


I step-by-step the check, to ensure I have done the thing correctly.

XCode Target Settings

enter image description here

  1. My app Bundle identifier is com.yocto.xxx
  2. My iCloud cointainer is iCloud.com.yocto.xxx

iCloudKit Console

enter image description here

  1. I can see the container iCloud.com.yocto.xxx is created in iCloudKit console.
  2. I am still do not see my own app schema yet. It is a simple entity called Todo with 2 columns – https://github.com/yccheok/xxx/blob/main/xxx/xxx.xcdatamodeld/xxx.xcdatamodel/contents

Sanbox tester account

enter image description here

  1. I created a sandbox tester account from App Store Connect/ Users and Access.
  2. I then use the sandbox tester account, to login from web to https://www.icloud.com/ . Login has no issues.

Login to Simulator

enter image description here

  1. Login to simulator has no issue

Minimal reproducible example

Here’s the XCode I use for this testing

https://github.com/yccheok/xxx


Do you have idea what’s went wrong in between, which causes me to keep getting Invalid bundle ID for container? Do you have any suggestion what else steps I can try on?

Thanks.

[ad_2]

Source link

Leave a Reply

Your email address will not be published.