Cloudkit keeps giving Create Permission Error even when all permission are rightly set

110 Views Asked by At

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

1

There are 1 best solutions below

0
On

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.