I'm using a public iCloud database in my app, which works great and is up on the store.
On updating my app to a new version (with Xcode 7 on iOS9) I get a crash on the line :
CKContainer * container = [CKContainer containerWithIdentifier:@"iCloud.com.identifier"];
*** Terminating app due to uncaught exception 'CKException', reason: 'The application is missing required entitlement com.apple.developer.icloud-services'
This happens ONLY the first launch of the app after updating, and only on iOS9. After that first (update) launch, the app launches and iCloud works as expected.
I can recreate the crash consistently by downloading the current store version of the app, then running the updated app from Xcode 7.
If I do the same steps (download production app, and update) using iOS8, I do not have the same crash.
I'm guessing this is an iOS9 or Xcode 7 bug. Any ideas?
EDIT :
This actually happens on the first launch of the app on iOS9, regardless of whether I'm updating or just first installing.
Toggling iCloud didn't work for me. Reinstalling the app didn't work either. The problem seems to happen whenever I have break points enabled. If I turn these off it runs without any problem.
Toggling the iCloud Capability on and off seems to have fixed it.
For me toggling the iCloud capability off/on was the way to fix it, due to after that in the entitlements file a new key is created: "APS Environment" and its value "production" or "deployment".
Changed the name of my app, therefore the entitlements file should have been different. Turning off and back on recreated the required file. Turning off breakpoints made it filter through (strange).
For me, I had Code Signing Entitlements designated for my Test target. So the app would build fine. But the unit tests would just quit no matter what. Clearing out the Code Signing Entitlements field from the Build Settings of the test target fixed the issue. After. Many. Hours.
After switching to a new version of Xcode I got this error. None of the other fixes worked. After looking closely I saw that the code signing identity had changed! When I put it back all worked.