title: CloudKit: Access development environment after deploy to AppStore?
body: <p>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.</p>
  
  <p>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).</p>
  
  <p>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 <strong>(and get access, aka login,</strong> to CloudKit dev environment).</p>
  
  <p>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.</p>
  
  <p><strong>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?</strong></p>
  
  <blockquote>
    <p>Edit: Realizing that my Question was not clear enough, here comes an attempt to clairify</p>
  </blockquote>
  
  <p>I can build and run from XCode. When trying to login to iCloud using </p>
  
  <p><code>self.container.requestApplicationPermission(CKApplicationPermissions.UserDiscoverability) {...}</code></p>
  
  <p>I get a</p>
  
  <p><code>CKApplicationPermissionStatus.Denied</code></p>
  
  <p>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.</p>
  
  <p><strong>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.</strong></p>