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?