问题
I'm building a test tool to verify content in CloudKit, but I want to be able to select the container's environment.
On iOS, you can select either the "Development" or the "Production" environment when you export your app for ad hoc testing, but you don't have that option on OS X. It always points to the "Development" environment.
Anyone knows, if there is a programmatically way to set or select what container environment you want to work with, either on OS X or iOS?
回答1:
In the entitlements file, add in the row of com.apple.developer.icloud-container-environment
and you can switch the value of that back and forth between Development
and Production
.
回答2:
I know this might be a bit late for those who posted but for others with the same problem, in the entitlement file change the com.apple.developer.icloud-container-environment
from Development
to Production
Then delete your app from your device so you get a clean build. When you run it, it should work. The key is to have a clean build.
回答3:
UPDATE: this changed in later versions of CloudKit, please ignore this and see the accepted answer.
No, there is no way to do that.
While you can access the same container as your iOS app, you can only access the "Development" environment until you export your application as a Mac App to the App Store (which is probably not your goal for a test tool).
The App Store application again would only be able to access the "Production" environment.
There is no other API to access CloudKit containers in a specific environment.
来源:https://stackoverflow.com/questions/27364035/cloudkit-switch-container-environment-from-development-to-production