Reputation: 232
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.
I verified that the APS Environment value is in the entitlements .plist.
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?
Upvotes: 5
Views: 779
Reputation: 55
open .entitlements file
and then add "aps-connection-initiate" key and set the value to true
That worked for me
Upvotes: 0
Reputation: 904
If you are facing this in simulator. Go to Device -> Erase all content ad settings..
And reinstall the app.
Upvotes: 0
Reputation: 279
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.
Upvotes: 4