CloudKit - “Invalid bundle ID for container”

心已入冬 提交于 2019-12-22 13:59:22

问题


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:

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

What I am doing wrong ?


回答1:


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




回答2:


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)
    }
}



回答3:


Having same issue on CloudKit:"Invalid bundle ID for container", and Dave helped to fix and back to business!



来源:https://stackoverflow.com/questions/46144170/cloudkit-invalid-bundle-id-for-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!