Reputation: 97
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.
Upvotes: 1
Views: 662
Reputation: 311
Be sure that you are logged in through iCloud. Go to Device Settings -> iCloud.
Also take a look at this article. And code example.
Upvotes: 1
Reputation: 1590
You need to deploy your Development CloudKit Environment to Production one. Check Deployment tab in icloud.developer.apple.com
Upvotes: 3