How to fix “Field ‘recordName’ is not marked queryable” in CloudKit

The issue

While writing an iOS app in Swift using CloudKit and CoreData with NSPersistentCloudKitContainer, I ran into the issue “Field ‘recordName’ is not marked queryable” and couldn’t see an obvious solution. Searching online didn’t give many helpful results either.

“Field ‘recordName’ is not marked queryable” error message in CloudKit Dashboard

This error message would show up in the CloudKit Dashboard as well as in the debug console when trying to make a CloudKit query from my app. My CloudKit scheme, automatically generated by NSPersistentCloudKitContainer, didn’t have a field named “recordName” for me to mark queryable.

There is no “recordName” field here


It turns out the solution is quite simple, though not immediately obvious. It’s simply to mark “recordID” as queryable, even though the error message says “recordName”.

To do so, open the CloudKit dashboard, open the development environment for your app, the under Schema -> Indexes, select the record type you’re trying to query. Click the plus button to add a new index, and mark “recordID” as Queryable and click Save.

Mark “recordID” as Queryable even though the error says “recordName”

That field should now be queryable in both the CloudKit Dashboard and in your code using CKQueryOperation.

Field is now queryable

One thought on “How to fix “Field ‘recordName’ is not marked queryable” in CloudKit

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: