Use production CloudKit during development?
My iOS and Mac apps have been launched to the App Store and all of my users, including myself, are using the CloudKit production database. My question is, is there any way to target the production environment for my development builds? It seems there is no way to target the production environment outside of the Mac App Store, and for iOS, only Ad Hoc distribution can target the production environment.
Solution 1:
Add the following entry to your entitlements file and perform a clean build.
This allows you to run your application in Xcode with the CloudKit in the production mode.
Entry to add: com.apple.developer.icloud-container-environment
with
value: Production
.
Note: Will not work with simulator
Solution 2:
From the iCloud Design Guide https://developer.apple.com/library/mac/documentation/General/Conceptual/iCloudDesignGuide/DesigningforCloudKit/DesigningforCloudKit.html#//apple_ref/doc/uid/TP40012094-CH9-SW1
During development, Xcode automatically points your app to the development environment. Before you ship your app, configure your app using the distribution workflow. In this workflow, Xcode lets you choose whether you want to target the development or production environment and adds the com.apple.developer.icloud-container-environment entitlement to your app with the value you selected. Prior to shipping, be sure to configure your app for the production environment. Apps that target the development environment will be rejected by the App Store.
Per you comment here are some additional thoughts: Per Apple guideline, you should use the development env as long as you are still developing what is the best Data Schema for your application, and to allow faster development. Then Apple suggests to deploy to production and test on it, before giving to customer. So I think the answer is that it depends on where you are in the product development cycle. If you are in early stages use the dev env. If you have customers in the field then I would use the production env for production as long as it serves my needs. If I am developing new features requiring schema changes you should only develop those in the dev env until you are confident deploying them to production will not break anything for existing users and allow them a smooth transition. Hope this help.
Solution 3:
I am not sure whether setting "the com.apple.developer.icloud-container-environment entitlement" to "Production" will work on a device running from Xcode - it doesn't work for me on the simulator.
But you could make yourself an 'internal reviewer' and run a new version using TestFlight. TestFlight uses the Production Environment.