I've created a new record type in my public CloudKit database (for the sake of example iCloud.my.container.name) using the CloudKit dashboard. I have not added any custom fields to the object and I've made the recordName field Queryable and the createdAt field Sortable.
I started a new SwiftUI project in Xcode 11 and set up a convenience function to access the CloudKit records:
Inside my SwiftUI view, I have a property for the CKContainerHelper:
In the .onAppear, I have a call to self.helper.fetchLatestRecord(), but every time I run the App to request my custom record type (myrecord) I receive the following error:
I don't see a way to mark my custom type as indexable in the iCloud developer portal.
I started a new SwiftUI project in Xcode 11 and set up a convenience function to access the CloudKit records:
Code Block final class CKContainerHelper: ObservableObject { @Published var latestCreationDate: Date? func fetchLatestRecord() { let truePredicate = NSPredicate(value: true) let query = CKQuery(recordType: "myrecord", predicate: truePredicate) query.sortDescriptors = [ NSSortDescriptor(key: RecordKey.creationDate, ascending: false) ] CKContainer .default() .publicCloudDatabase .perform(query, inZoneWith: .default) { [weak self] records, error in if let creationDate = records?.first?["creationDate"] as? Date { self?.latestCreationDate = creationDate } if let error = error { print("Encountered error: \(error)") } } } }
Inside my SwiftUI view, I have a property for the CKContainerHelper:
Code Block @ObservedObject var helper = CKContainerHelper()
In the .onAppear, I have a call to self.helper.fetchLatestRecord(), but every time I run the App to request my custom record type (myrecord) I receive the following error:
Code Block <CKError 0x600001252ee0: "Invalid Arguments" (12/2015); server message = "Type is not marked indexable"; uuid = <some uuid>; container ID = "iCloud.my.container.name">
I don't see a way to mark my custom type as indexable in the iCloud developer portal.
No, your original message was clear. Apologies for missing your mention of your existing indexes.
The error you are seeing indicates that there are no indexes on any field for the recordType in question. If you certain that the indexes you mention are in place for the myrecord recordType, please file a Feedback Assistant report, as we should investigate this further. Report should include your container name and, ideally, device logs from a reproduction of your code seeing this error. Thanks.
The error you are seeing indicates that there are no indexes on any field for the recordType in question. If you certain that the indexes you mention are in place for the myrecord recordType, please file a Feedback Assistant report, as we should investigate this further. Report should include your container name and, ideally, device logs from a reproduction of your code seeing this error. Thanks.