7

I've just create a project in Xcode 9 beta 6 and add this code:

let privateDB = CKContainer.default().privateCloudDatabase
let greatID = CKRecordID(recordName: "GreatPlace")
let place = CKRecord(recordType: "Place", recordID: greatID)

privateDB.save(place) { (record, error) in
        if error != nil {
            let er = (error as! CKError).errorUserInfo
            print("Error: \n")
            print("CKErrorDescription: \(er["CKErrorDescription"]!)\n")
            print("ContainerID: \(er["ContainerID"]!)\n")
            print("NSDebugDescription: \(er["NSDebugDescription"]!)\n")
            print("NSUnderlyingError: \(er["NSUnderlyingError"]!)\n")
            print("NSLocalizedDescription: \(er["NSLocalizedDescription"]!)\n")
            print("ServerErrorDescription: \(er["ServerErrorDescription"]!)\n")
        }
        if record != nil {
            print("record: \(record!)")
        }
 }

and add this capabilities:

enter image description here

and when I run the code I receive this error message:

enter image description here

What I am doing wrong ?

4 Answers 4

12

There was a bug causing some associations to be missed. That bug has been fixed and we automatically fixed the container/app associations that were broken during that time.

If for some reason you still need to redo an association you can either use the Capabilities pane in Xcode or use developer.apple.com -> Certificates, Identifiers & Profiles -> App IDs -> pick the ID -> Edit -> Edit under iCloud -> check the box for the container to disassociate, save, then re-associate.

If you're still stuck please email cloudkit[at]apple.com

9
  • Hi Dave, thanks for your answer. Actually, every new project I tried to create using CloudKit has the same problem. What should I do ? Send only the bundle ID and Container ID I'm currently working on ? Regards !
    – Sebastian
    Sep 14, 2017 at 15:43
  • I have the same error, I tried your solution but it doesn't work. Just nothing changed :( Oct 23, 2020 at 13:50
  • Just encountered the same issue with Xcode 12.5. Playing with the Capabilities pane in Xcode didn't help, but the 2nd solution (reassociating via developer.apple.com) did. Of course I had to regenerate the provisioning profiles for the app after editing the App ID. May 31, 2021 at 23:17
  • I've set up iCloud on a few projects without seeing this issue. However I recently encountered it. I noticed a "iCloud Container Assignment" button; the container I set up in Xcode was not associated there.
    – James
    Oct 1, 2021 at 11:26
  • 3
    After many frustrating hours I came to this answer. What worked for me is: 1. deselect the container on Xcode, 2. deselect container on developer.apple.com (and save), 3. select container again on website, 4. regenerate profiles and finally 5. select container on Xcode.
    – vauxhall
    Nov 28, 2021 at 16:59
0

My friend and I are having the same issue. We made 2 different projects and both of them had the same error message "Invalid bundle ID for container" which is CKError case 10 .

We are calling our fetch function to get the default "Users" record in the viewDidLoad.

func fetchWorkoutCompleted(completion: @escaping (Error?) -> Void = { _ in }) {
    cloudKitManager.fetchRecord(ofType: "Users", sortDescriptors: nil) { (records, error) in
        if let error = error {
            print(error.localizedDescription)
            completion(error)
            return
        }
        guard let records = records else { completion(nil); return }
        completion(nil)
    }
}
2
  • Do you think it could be an environment problem?
    – Sebastian
    Sep 12, 2017 at 15:39
  • Yeah, it might have something to do with the Apple's Keynote. I have several small cloudKit projects from the past that are working fine.
    – pcnick13
    Sep 12, 2017 at 20:15
0

Using Xamarin.IOS, I had to select manual provisioning rather than automatic provisioning in the info.plist file.

0

Had the same issue. what worked for me was changing the iCloud group name.

  • Before it was something like this: iCloud.com.companyName.appName.randomString

  • After changing to: iCloud.com.companyName.randomString it started working and synchronising.

If after adding the new container it's red press the refresh button(from under the groups) and try a clean install on your phone and it should work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.