CloudKit - "容器的无效包ID"

Seb*_*ian 2 swift cloudkit xcode9beta6

我刚刚在Xcode 9 beta 6中创建了一个项目并添加了以下代码:

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!)")
        }
 }
Run Code Online (Sandbox Code Playgroud)

并添加此功能:

在此输入图像描述

当我运行代码时,我收到此错误消息:

在此输入图像描述

我做错了什么?

Dav*_*ing 5

有一个错误导致一些关联被遗漏.该错误已得到修复,我们会自动修复在此期间损坏的容器/应用程序关联.

如果由于某种原因您仍需要重做关联,您可以使用Xcode中的功能窗格或使用developer.apple.com - >证书,标识符和配置文件 - >应用程序ID - >选择ID - >编辑 - >编辑下iCloud - >选中容器的框以取消关联,保存,然后重新关联.

如果您仍然卡住了,请发送电子邮件至cloudkit [at] apple.com

  • 经过许多令人沮丧的小时后,我得出了这个答案。对我有用的是:1.在Xcode上取消选择容器,2.在developer.apple.com上取消选择容器(并保存),3.在网站上再次选择容器,4.重新生成配置文件,最后5.在Xcode上选择容器。 (5认同)
  • 几年后,我在 Xcode 13 中遇到了这个问题 (3认同)