0

Added iCloud to a working iOS app, with data stored in the public database. I have to log on to iCloud in the simulator, but that done, the app runs fine in the simulator. On an iPad, the program crashes on the following statement:

CKContainer * dbContainer = [CKContainer defaultContainer];

The app is terminated "due to uncaught exception 'CKException', reason: 'The application is missing required entitlement com.apple.developer.icloud-services'

When I turn on the iCloud capability in XCode, XCode creates an entry in the .entitlements file for com.apple.developer.icloud-services, with one item in the array: a string with value "CloudKit".

On my iPad I am logged in to iCloud in the same way as on the simulator.

I have been through Apple's entitlement troubleshooting guide in detail several times, I have searched every way I know how, and I can't figure out why this fails. I did find and read the posts suggested as duplicates and none of the solutions suggested worked for me.

After posting this question, I went through the entitlement troubleshooting guide one more time and found the following entitlement section in the built app:

<dict>
    <key>keychain-access-groups</key>
    <array>
        <string>PTXZTRRTHH.*</string>       
    </array>
    <key>get-task-allow</key>
    <true/>
    <key>application-identifier</key>
    <string>PTXZTRRTHH.com.quipzl.Quipzl</string>
    <key>com.apple.developer.ubiquity-kvstore-identifier</key>
    <string>PTXZTRRTHH.*</string>
    <key>com.apple.developer.icloud-services</key>
    <string>*</string>
    <key>com.apple.developer.icloud-container-environment</key>
    <array>
        <string>Development</string>
        <string>Production</string>
    </array>
    <key>com.apple.developer.icloud-container-identifiers</key>
    <array>
        <string>iCloud.com.quipzl.Quipzl</string>
    </array>
    <key>com.apple.developer.icloud-container-development-container-identifiers</key>
    <array>
        <string>iCloud.com.quipzl.Quipzl</string>
    </array>
    <key>com.apple.developer.ubiquity-container-identifiers</key>
    <array>
        <string>iCloud.com.quipzl.Quipzl</string>
    </array>
    <key>com.apple.developer.team-identifier</key>
    <string>PTXZTRRTHH</string>
    <key>aps-environment</key>
    <string>development</string>
</dict>

And the app does run on my iPad - until execution reaches the code above, when it throws an exception. Why?

Jim Wanner
  • 11
  • 3
  • Possible duplicate of [The application is missing required entitlement com.apple.developer.icloud-services'](http://stackoverflow.com/questions/32728300/the-application-is-missing-required-entitlement-com-apple-developer-icloud-servi) – jose920405 Apr 18 '16 at 21:36
  • Not a duplicate - my app hasn't been in the app store yet, and it fails every time in iOS 9, not just the first time. Toggling iCloud on and off doesn't fix the problem. – Jim Wanner Apr 19 '16 at 12:02

1 Answers1

0

This crash was not due to any missing entitlements, though the exception said it was. I don't know exactly what fixed the problem, but I do know the process that worked, as follows:

1) create a new iOS project of the same type an make sure it runs.

2) enable CloudKit in the new app, and add #import "CloudKit/CloundKit.h" in the default controller created by XCode.

3) add the statement "[CKContainer defaultContainer];" in the viewDidLoad() method.

4) run the app again and make sure it doesn't crash on the added statement.

5) go through all of the app properties in the old app and make sure all of the values are identical to those in the new app.

This last step included around a dozen value changes, and solved the problem: the old app no longer crashes trying to access iCloud.

Jim Wanner
  • 11
  • 3