Provisioning issue with CoreDataCloudKitDemo

I've been struggling to get the CoreDataCloudKitDemo working. I've updated to Xcode 13 and followed the documented instructions closely. However, I'm getting this error:

Provisioning profile "Mac Team Provisioning Profile: com.____.apple-samplecode.CoreDataCloudKitDemo" doesn't include the aps-environment entitlement.

A bit of searching says this error is due to Push Notifications not being enabled. However, I do have them enabled. I cannot figure out why this won't run.

I've also encountered this issue. I have narrowed it down to there being different aps-environment keys added to the [YourProject].entitlements file:

  • aps-environment for iOS and
  • com.apple.developer.aps-environment for Mac

Signing then fails because the provisioning profile that is provided only has one of these (depending on the platform)

I have raised feedback FB9194385 for this.

In the meantime you can create separate entitlements files per target as described here: https://stackoverflow.com/questions/43086070/how-to-set-different-entitlements-file-for-different-targets

One other workaround I found is that the error is related to running the app in the Mac simulator. Changing the simulator to an iPhone device works fine.

If you follow the read.me instructions very carefully and also ensure that in Core Data Default Configuration, Used with CloudKit is check the app will compile and run in Xcode 13.1 with Simulator set to iPhone 12 iOS 15.

I had the same issue and fooled around with the Team, Bundle Identifier and iCloud Container names in Signing and Capabilities until they all matched. Xcode tries to help with the naming but its not intuitive and may mess up your names.

I've spent hours on this but for some reason Xcode doesn't import the data schema into the CloudKit Dashboard. All in all a very frustrating experience given the code in CoreDataStack.swift doesn't even look like any of the code that Nick Gillett presented at WWDC21. Nick presented code for a public database but the sample app file has configurations for private and shared that are completely different.

On top of all that they didn't post a SwiftUI version. It's UIKit only.

Provisioning issue with CoreDataCloudKitDemo
 
 
Q