CloudKit Container

Hi,


It seems like iCloud is unable to create the container. I tried it on multiple device as well as the simulator. I get the below error message on all of them,


ErrorHandler.Fail: Bad Container: the specified container is unknown or unauthorized.CKError.Code: 5

ErrorHandler.Fail: Bad Container: the specified container is unknown or unauthorized.CKError.Code: 5

ErrorHandler.Fail: Bad Container: the specified container is unknown or unauthorized.CKError.Code: 5

ErrorHandler.partialFailure for 1 items; CKPartialErrorsByItemIDKey: {

"<CKRecordZoneID: 0x600002c1e8a0; ownerName=__defaultOwner__, zoneName=PortraitObjectsZone>" = "<CKError 0x6000022a48d0: \"Bad Container\" (5/1014); \"Couldn't get container configuration from the server for container \"iCloud.shervin.shirazian.portrait\"\">";

}

ErrorHandler.Fail: Bad Container: the specified container is unknown or unauthorized.CKError.Code: 5

ErrorHandler.Fail: Bad Container: the specified container is unknown or unauthorized.CKError.Code: 5

ErrorHandler.Fail: Bad Container: the specified container is unknown or unauthorized.CKError.Code: 5

ErrorHandler.Fail: Bad Container: the specified container is unknown or unauthorized.CKError.Code: 5

Replies

This error code is:


Un-provisioned or unauthorized container. Try provisioning the container before retrying the operation.


Go to your proyect > Target > Capabilities > Enable ICloud > Select CloudKit > Use default container

You need to enable iCloud under the Capabilities tab of your target app. In that you will select the container you want to use. Chose 'Use default contaoner' as suggested by ManuelMB unless you want a custom container to be able to share data with other apps.

In Xcode 11.1 there is no "use default container" option as far as I can tell. I keep getting: Bad Container" (1014); "Couldn't get container configuration from the server for container when trying to use the default container.


Using +containerWithIdentifier: and manually typing in the container id seems to work though...any way to express a given identifier as default so I can use the +defaultContainer factory?


Guess I can try to manually create the container iCloud.\(application-identifier). No way to delete development containers, so I'll have an extra container in my dashboard later. Guess I'll just use the current identifier i have.

Did this work?

I get "create operation not permitted"

The container to use is the one called "iCloud.X" where "X" is the bundle identifier of the app.

In xcode 11.1 there is no default container. You need to click add container in the capabilities section. To call the container in the code you need to write "let container = CKContainer(identifier: "the name of the container")".

My code is still working with (in Objective C)


    CKContainer *defaultContainer=[CKContainer defaultContainer];


where I chose "iCloud.X" as the container (where X is the bundle identifier).