我刚刚下载了 Xcode 14 候选版本,并且在启动时开始出现以下崩溃错误(没有尝试其他测试版)。我没有对代码库进行任何更改。 CloudKit 之前运行良好:
[CK] BUG IN CLIENT OF CLOUDKIT: Not entitled to listen to push notifications. Please add the 'aps-connection-initiate' entitlement.
在开发者门户的证书、标识符和配置文件下,我已验证推送通知已启用。
为了解决这个问题,我尝试删除并重新添加推送通知权利。
我关闭了自动签名,然后再次将其重新打开。我清理了构建并删除了派生数据。我还尝试切换回 Xcode 13.4.1,一切都重新开始工作 - 不幸的是,这不是解决方案。
错误发生在调用container.loadPersistentStores时。
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? {
这只是 Xcode beta 错误(在候选版本中)吗?有办法解决吗?
我今天也刚刚在 Xcode 14.0 RC 上遇到了这个错误。这是一个基本上全新的项目,所以我认为新版本一定有些奇怪。
为了解决这个问题,我只是做了错误所说的事情:
<key>aps-connection-initiate</key>
<true/>
将其添加到应用程序的 Info.plist 中,然后它再次运行得很好。 SwiftUI 预览也再次开始工作。
如果您在模拟器中遇到此问题。转到
Device -> Erase all content ad settings..
并重新安装应用程序。
打开.entitlements 文件
然后添加“aps-connection-initiate”键并将值设置为 true
这对我有用