Type is not marked indexable

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:
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.
Answered by in 620376022
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.
In the CloudKit Dashboard, try adding a QUERYABLE index on the recordName field.
I'm sorry if it wasn't clear above, but I have marked recordName as Queryable and createdAt as Sortable.
Accepted Answer
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.
Type is not marked indexable
 
 
Q