4

I just downloaded the Xcode 14 release candidate and I started getting the following crashing error on startup (didn't try the other betas). I made no changes in the codebase. CloudKit was working fine before:

[CK] BUG IN CLIENT OF CLOUDKIT: Not entitled to listen to push notifications. Please add the 'aps-connection-initiate' entitlement.

Under Certificates, Identifiers & Profiles in the Developer portal, I've verified that push notifications are enabled.

To fix, I tried removing and re-adding the push-notifications entitlement.

enter image description here

I verified that the APS Environment value is in the entitlements .plist.enter image description here

I switched off automatic signing and then turned it back on again. I cleaned the build and deleted derived data. I also tried switching back to Xcode 13.4.1 and everything started working again - unfortunately, not a solution.

The error occurs right as container.loadPersistentStores is called.

lazy var persistentContainer: NSPersistentCloudKitContainer = {
        /*
         The persistent container for the application. This implementation
         creates and returns a container, having loaded the store for the
         application to it. This property is optional since there are legitimate
         error conditions that could cause the creation of the store to fail.
         */

        let container = NSPersistentCloudKitContainer(name: "not_real_name")
        
        guard let description = container.persistentStoreDescriptions.first else {
            fatalError("No descriptions found (AppDelegate.persistentContainer)")
        }
        
        description.setOption(true as NSObject, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)
        container.loadPersistentStores(completionHandler: {
            (storeDescription, error) in
            if let error = error as NSError? {

Is this just an Xcode beta bug (in the release candidate)? Is there a way to work around it?

andrewlewisdev
  • 202
  • 2
  • 11

3 Answers3

4

I also just ran into this error today, on the Xcode 14.0 RC. It was on a basically brand new project so I figured it must be something odd with the new version.

To fix, I just did what the error said:

    <key>aps-connection-initiate</key>
    <true/>

Added that to the app's Info.plist, then it ran again just fine. Also SwiftUI previews started working again.

Jason Clardy
  • 239
  • 3
  • 6
0

If you are facing this in simulator. Go to Device -> Erase all content ad settings.. And reinstall the app.

Rakitha
  • 894
  • 1
  • 12
  • 25
0

open .entitlements file

and then add "aps-connection-initiate" key and set the value to true

That worked for me

Ali Al-Hudhud
  • 55
  • 2
  • 7