Search code examples
iosiphoneswiftios8cloudkit

CloudKit from iPhone


Trying to fetch some data from CloudKit, and I have some strange problem; If I run the code through the simulator for iPhone 5 everything works fine, but all other devices get an error fetching data. If I connect my iPhone 6 to the computer and run it there, it works fine. If I test it through TestFlight it doesn't work on iPhone 4s, iPhone 5 or iPhone 6.

let cloudContainer = CKContainer.defaultContainer()
let publicDatabase = CKContainer.defaultContainer().publicCloudDatabase
let predicate = NSPredicate(value: true)
let query = CKQuery(recordType: "Employee", predicate: predicate)
publicDatabase.performQuery(query, inZoneWithID: nil, completionHandler: {
    results, error in
    if error == nil {
         //some code
    }
    else {
         println(error)
    }})

Error:

did not find required record type.

I have checked all records type, data and so in CloudKit Dashboard, and remember it workes fine in the iPhone 5 simulator (if I add/delete data in CloudKit Dashborad, it reflects in the app).

Any help is appreciated.


Solution

  • You need to deploy your Development CloudKit Environment to Production one. Check Deployment tab in icloud.developer.apple.com