1
votes

iCloud integration works in a development environment and fails in a production environment. It would appear that the custom record zones are not being deployed alongside the record types. Allow me to explain.

Configuration: The iCloud development schema we configured has more than one distinct custom record zones, each with their own record types. In development mode, it works perfectly - data persists across devices, and all of the records and their zones are visible on the iCloud dashboard.

Observation: As we deployed the schema to the production environment, however, the custom record zones were left out. The record types were successfully deployed, but they remain useless since the server is unaware of the custom record zones.

You won't be shocked to learn that every time a production app tries to sync with iCloud, it is told (an error is logged) that the record type does not exist.

What we have tried: We have tried rebuilding the iCloud container from scratch, and we have tried manually creating the custom record zones on the dashboard. Neither worked.

Additionally, we deployed a (seemingly) identical schema for a different app just 1-2 weeks ago and it went off without any issue.

Does anyone have any ideas as to what the issue might be and how to fix it?

1

1 Answers

3
votes

Deploying to production from the CloudKit dashboard only copy record types, security roles, and subscription types.

The first time you deploy your app, CloudKit copies the container schema to the production environment. This includes the record types, security roles, and subscription types, but not the records that you created in the development environment.

You have to create your custom record zones using CKModifyRecordZonesOperation operation.

You could check if your custom zones have been created in your AppDelegate, maybe using an UserDefaults key, something like CustomZonesCreated. If not, call to the function in which you will create your custom zones.

More info at CloudKit Quick Start guide