3

I am getting a very generic error for a CloudKit query. I am not sure how to fix it. Does anyone have any suggestions?

The error is <CKError 0x17065c230: "Internal Error" (1/2005)> Error occurred. Error = <CKError 0x174648370: "Internal Error" (1/2005)>

My code is:

    override func viewDidLoad() {
    super.viewDidLoad()
    let database = CKContainer.defaultContainer().publicCloudDatabase
    let container = CKContainer.defaultContainer()
    let publicDB = container.publicCloudDatabase
    let data = CKRecord(recordType: "theUsers")

    var predicate = NSPredicate(value: true)
    let myQuery = CKQuery(recordType: "theUsers", predicate: predicate)

    var mySelfie = matchedSelfie

    publicDB.performQuery(myQuery, inZoneWithID: nil) {
        results, error in
        if error != nil {
            println(error)

        } else {
            for record in results{
                if let aselfie = record.stringForKey("selfie") { //Optional binding
                    mySelfie.append(aselfie) //Append to string array

                    mySelfie.append(aselfie)
                    return ()
                }

            }}}

}
JustSid
  • 25,168
  • 7
  • 79
  • 97
Andy Dewan
  • 245
  • 1
  • 2
  • 18
  • 2
    Updated your tags and title. Note that this is not an Xcode error, Xcode is just the IDE. – JustSid Feb 03 '15 at 03:13
  • This is a generic CloudKit error message. Do you only get this with this piece of code or is nothing working? Did you setup the cloud kit capabilities OK? What if you first remove the app from your device and then try it again? Don't you get more information in the error message? Usually there is also a specific reason. – Edwin Vermeer Feb 04 '15 at 09:06
  • It is only this piece of code that gives the error. I'm able to successfully write to the CK. – Andy Dewan Feb 04 '15 at 12:51
  • It could be related to a comment posted in [https://stackoverflow.com/q/35321975/1359088](https://stackoverflow.com/q/35321975/1359088): From Apple's CloudKit Quick Start Guide: "In development, when you run your app through Xcode on a simulator or a device, you need to enter iCloud credentials to read records in the public database. In production, the default permissions allow non-authenticated users to read records in the public database but do not allow them to write records." – James Toomey Mar 15 '18 at 22:09

1 Answers1

2

I got the same error. You can get more information by looking at the iCloud Steps section in the Capabilities tab of your project:

  1. In the Project Navigator, select your project
  2. Select your Target
  3. Select Capabilities
  4. Expand the iCloud section
  5. Assuming you have the CloudKit service enabled, you should see a list of steps you must perform. (E.g. Add the "iCloud" entitlement to your App ID.)

More likely than not, at least one of those shows a red error icon instead of a checkmark.

enter image description here

Senseful
  • 86,719
  • 67
  • 308
  • 465