icloud-container-environment with NSPersistentCloudKitContainer

The com.apple.developer.icloud-container-environment provides the option to set "the development or production environment to use for the iCloud containers."

My app uses Core Data, and I have implemented NSPersistentCloudKitContainer. When I am not working on schema changes, I would like my local development builds to still access the production Core Data store. However, setting this entitlement to "Production" has not produced this result... the container is still listed as 'Staging' and I can see in the CloudKit Console that the Development container is being used.

Does this entitlement only apply to direct use of CloudKit, and not to NSPersistentCloudKitContainer? If it doesn't apply to the latter, is there another way to direct NSPersistentCloudKitContainer to use the Production container?

This is an iOS app though I am beginning work on a macOS version and would like to be able to do this in both environments.

Answered by babbage in 716783022

Do not be as dim witted as me! com.apple.developer.icloud-container-environment must be set in your .entitlements file, not your app's info.plist file! Additionally, if you have separate .entitlements files for your debug and release builds, be sure to set this value in the debug one.

Note that TestFlight builds and releases in the store are unaffected by this entitlement—they will always use the production environment regardless of whether this entitlement is set and regardless of what it is set to if it is set.

Accepted Answer

Do not be as dim witted as me! com.apple.developer.icloud-container-environment must be set in your .entitlements file, not your app's info.plist file! Additionally, if you have separate .entitlements files for your debug and release builds, be sure to set this value in the debug one.

Note that TestFlight builds and releases in the store are unaffected by this entitlement—they will always use the production environment regardless of whether this entitlement is set and regardless of what it is set to if it is set.

icloud-container-environment with NSPersistentCloudKitContainer
 
 
Q