I get the following error when trying to save a record to cloudkit
I have done everything
- Security Role Authenticated for the Record Type has Read, Write, and Create Permission
- I have tried resetting the development environment
- Interestingly, even after I disassociate the container from my application setting, the application still works
- My Query works fine- only saving fails
Here is my code
let publicDatabase = CKContainer.default().publicCloudDatabase
let record = CKRecord(recordType: "test")
record.setValue("test", forKey: "test")
publicDatabase.save(record) { (savedRecord, error) in DispatchQueue.main.async {
if error == nil {
print("saved")
} else {
print(error!)
print("Record Not Saved")
}
}
}
Any help will be greatly appreciated
You most likely have an issue with the Apple ID on the device/simulator you are testing on. On your test device/simulator, go into Settings and make sure you are signed into a valid Apple ID AND that iCloud Drive is turned on. All users must be properly authenticated with iCloud in order to make changes to the database.