CloudKit "Field 'recordName' is not marked queryable"

8 min read

The error message "Field 'recordName' is not marked queryable" suggests that you are trying to perform a query on the 'recordName' field in CloudKit, but it is not marked as queryable.

In CloudKit, only the fields marked as queryable are allowed to be used in queries. By default, all record fields are not queryable, meaning you cannot search for records based on those fields. To perform queries on a specific field, you need to mark it as queryable in your CloudKit schema.

To mark a field as queryable, you can do the following:

  1. Open your CloudKit dashboard.
  2. Navigate to the schema editor for the record type containing the field you want to make queryable.
  3. Find the field in question and click on it.
  4. In the field's options, enable the "Queryable" checkbox.
  5. Save your changes.

After marking the field as queryable, you should be able to perform queries on that field without encountering the above error. Remember to deploy the schema changes to update your CloudKit environment with the new field settings.

It's worth noting that the 'recordName' field in CloudKit is a system field that uniquely identifies each record and is automatically generated. By default, system fields are not queryable, so if you want to perform queries based on record names, you should consider creating a custom field explicitly for that purpose and mark it as queryable.