I have built a CloudKit app with a rather complex record graph to prove our MVP with our customers. Development has been next to flawless and every problem could easily be derived to crappy code.
Now we've deployed our first version of the app. The review process was Kafka like with the review team being unable to login to cloudkit. I had to use the life line of one of our AppleTS questions to get a checklist for the review team to follow (which basically said - log out and login with another iCloud account if the one you are using doesn't work).
We got through the review process and the app is live on the AppStore. But now the real mess starts on my part. I need to fix a couple of bugs but now I cannot access the app if it is built with my debug settings. As a matter of fact there doesn't seem to be any way I can build and run (and get access, aka login, to CloudKit dev environment).
I've found some obscure references on the net talking about setting up my dev and prod environments correctly, but as far as I know I've simply followed the book, and the Apple Docs on Design Tips for CloudKit simply doesn't solve the problem.
In short! How do I manage a Dev environment and a Prod environment in CloudKit after release, and how do I access Dev environment from a build by XCode sent to my device, to continue development after release?
Edit: Realizing that my Question was not clear enough, here comes an attempt to clairify
I can build and run from XCode. When trying to login to iCloud using
self.container.requestApplicationPermission(CKApplicationPermissions.UserDiscoverability) {...}
I get a
CKApplicationPermissionStatus.Denied
status back. No error, just simply a denied state back. Looking at Settings->iCloud->iCloud Drive-> "Look me up by Email" I sometimes find my switch for my app enabled, and sometimes disabled. Trying to switch the switch crashes the Settings app. Even going to www.icloud.com and setting my discoverability settings for my app does not remedy the problem. Reinstalling the app from App Store or Testflight works like a charm, but of course runs towards to Prod environment.
So the question remains; How do I manage my Dev and Prod environments in such a way that I can access (login to, if you like) my Dev environment when developing, while I have an app for sale in the AppStore or production builds in TestFlight for beta testing.
I was stuck on that issue too couple of days ago. I totally agree with everything @adamsde1 wrote before me, but I would like to share what I did.
So, first things first, I built an app with CloudKit capabilities. It was easy stuff, just an array of objects that could be shared and edited by all app users (Public DB). Assuming that you know how to do that, let us move on to the issue.
As far as I understood, there are two types of databases Development and Production. Development is used (as you might guess) for development and Production for TestFlight and AppStore versions.
To switch your app from Development to Production, you go to Entitlements in Project Navigator and add
com.apple.developer.icloud-container-environment
row and set its String value toProduction
. Also, inAPS Environment
row you need to set String value toproduction
as well.The next step will be modifying your DB on AppStore Connect. When you enter your Dashboard go to your Container and press the little gear and select
Deploy Schema to Production...
This solved my issue when the app did not work on TestFlight, but everything was fine while deploying from Xcode. Hope this helps someone too