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 icloud capabilities with Use default containers and when I run the code I receive this erros message:
Error:
CKErrorDescription: Error saving record <CKRecordID: 0x7fd8e9684560; recordName=GreatPlace, zoneID=_defaultZone:__defaultOwner__> to server: Invalid bundle ID for container
ContainerID: iCloud.com.gazapps.MyCloudKit
NSDebugDescription: CKInternalErrorDomain: 2007
NSUnderlyingError: <CKError 0x60400005d0d0: "Permission Failure" (2007); server message = "Invalid bundle ID for container"; uuid = 73EDDA3F-25B1-4B22-8E8E-4F6B27B9AB06; container ID = "iCloud.com.gazapps.MyCloudKit">
NSLocalizedDescription: Error saving record <CKRecordID: 0x7fd8e9684560; recordName=GreatPlace, zoneID=_defaultZone:__defaultOwner__> to server: Invalid bundle ID for container
ServerErrorDescription: Invalid bundle ID for container
What I am doing wrong ?