在 iOS 中工作 NSPersistentCloudKitContainer 时获取错误堆栈跟踪

Posted

技术标签:

【中文标题】在 iOS 中工作 NSPersistentCloudKitContainer 时获取错误堆栈跟踪【英文标题】:Getting error stack trace when working NSPersistentCloudKitContainer in iOS 【发布时间】:2019-07-07 21:57:20 【问题描述】:

我正在尝试使用 Core Data 和 CloudKit 构建一个非常基本的应用程序。我在我的 Mac 上登录了我的 CloudKit 帐户,并按照说明运行 Apple 在其website 上提供的示例项目。

以示例项目为指导,我尝试使用here 提供的说明构建一个更简单的应用程序。

但是,在构建尝试运行我的示例项目后,我在控制台中收到以下错误堆栈跟踪:

CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](35): Validating options: <NSCloudKitMirroringDelegateOptions: 0x60000097f960> containerIdentifier:iCloud.com.cybermedia.CloudKitTest1 initializeSchema:YES ckAssetThresholdBytes:<null> operationMemoryThresholdBytes:<null> useEncryptedStorage:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName:<null> containerProvider:<PFCloudKitContainerProvider: 0x600002f602e0> scheduler:<null> notificationListener:<null> containerOptions:<null>
storeOptions: 
    NSInferMappingModelAutomaticallyOption = 1;
    NSMigratePersistentStoresAutomaticallyOption = 1;
    NSPersistentCloudKitContainerOptionsKey = "<NSPersistentCloudKitContainerOptions: 0x600002d73960>";
    NSPersistentHistoryTrackingKey = 1;
    NSPersistentStoreMirroringOptionsKey =     
        NSPersistentStoreMirroringDelegateOptionKey = "<NSCloudKitMirroringDelegate: 0x600001c7dc20>";
    ;

CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _setUpCloudKitIntegration](355): <NSCloudKitMirroringDelegate: 0x600001c7dc20>: Successfully enqueued setup request.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest](1854): <NSCloudKitMirroringDelegate: 0x600001c7dc20>: Checking for pending requests.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(1866): <NSCloudKitMirroringDelegate: 0x600001c7dc20>: Executing: <NSCloudKitMirroringDelegateSetupRequest: 0x60000232c2a0> 6D32A278-F996-438D-AA8D-950F438F6402
2019-07-06 01:10:45.443340-0400 CloudKitTest1[14002:3818396] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(769): <NSCloudKitMirroringDelegate: 0x600001c7dc20>: Failed to set up CloudKit integration for store: <NSSQLCore: 0x600001274000> (URL: file:///Users/fsyed/Library/Developer/CoreSimulator/Devices/2A838B6E-EF14-4F54-9230-7B747A6DDE9B/data/Containers/Data/Application/249463B2-7348-4DBA-9739-0DDEB0ECBA10/Library/Application%20Support/CloudKitTest1.sqlite)
Error Domain=NSCocoaErrorDomain Code=134400 "Unable to initialize without an iCloud account (CKAccountStatusNoAccount)." UserInfo=NSLocalizedFailureReason=Unable to initialize without an iCloud account (CKAccountStatusNoAccount).
CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(769): <NSCloudKitMirroringDelegate: 0x600001c7dc20>: Failed to set up CloudKit integration for store: <NSSQLCore: 0x600001274000> (URL: file:///Users/fsyed/Library/Developer/CoreSimulator/Devices/2A838B6E-EF14-4F54-9230-7B747A6DDE9B/data/Containers/Data/Application/249463B2-7348-4DBA-9739-0DDEB0ECBA10/Library/Application%20Support/CloudKitTest1.sqlite)
Error Domain=NSCocoaErrorDomain Code=134400 "Unable to initialize without an iCloud account (CKAccountStatusNoAccount)." UserInfo=NSLocalizedFailureReason=Unable to initialize without an iCloud account (CKAccountStatusNoAccount).
2019-07-06 01:10:45.444373-0400 CloudKitTest1[14002:3818396] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate recoverFromError:](1259): <NSCloudKitMirroringDelegate: 0x600001c7dc20> - Attempting recovery from error: Error Domain=NSCocoaErrorDomain Code=134400 "Unable to initialize without an iCloud account (CKAccountStatusNoAccount)." UserInfo=NSLocalizedFailureReason=Unable to initialize without an iCloud account (CKAccountStatusNoAccount).
CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate recoverFromError:](1259): <NSCloudKitMirroringDelegate: 0x600001c7dc20> - Attempting recovery from error: Error Domain=NSCocoaErrorDomain Code=134400 "Unable to initialize without an iCloud account (CKAccountStatusNoAccount)." UserInfo=NSLocalizedFailureReason=Unable to initialize without an iCloud account (CKAccountStatusNoAccount).
2019-07-06 01:10:45.445456-0400 CloudKitTest1[14002:3818396] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _recoverFromError:withMonitor:](1398): <NSCloudKitMirroringDelegate: 0x600001c7dc20> - Failed to recover from error: Error Domain=NSCocoaErrorDomain Code=134400 "Unable to initialize without an iCloud account (CKAccountStatusNoAccount)." UserInfo=NSLocalizedFailureReason=Unable to initialize without an iCloud account (CKAccountStatusNoAccount).
Recovery encountered the following error: (null)
CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _recoverFromError:withMonitor:](1398): <NSCloudKitMirroringDelegate: 0x600001c7dc20> - Failed to recover from error: Error Domain=NSCocoaErrorDomain Code=134400 "Unable to initialize without an iCloud account (CKAccountStatusNoAccount)." UserInfo=NSLocalizedFailureReason=Unable to initialize without an iCloud account (CKAccountStatusNoAccount).
Recovery encountered the following error: (null)
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _finishedRequest:withResult:](1883): Finished request: <NSCloudKitMirroringDelegateSetupRequest: 0x60000232c2a0> 6D32A278-F996-438D-AA8D-950F438F6402 with result: <NSCloudKitMirroringResult: 0x600002304ea0>
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest](1854): <NSCloudKitMirroringDelegate: 0x600001c7dc20>: Checking for pending requests.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(1869): <NSCloudKitMirroringDelegate: 0x600001c7dc20>: No more requests to execute.

我不断收到错误:

NSLocalizedFailureReason=Unable to initialize without an iCloud account 

谁能看到或帮助我确定我做错了什么?

【问题讨论】:

【参考方案1】:

您需要在模拟器上登录您的 iCloud 帐户

【讨论】:

以上是关于在 iOS 中工作 NSPersistentCloudKitContainer 时获取错误堆栈跟踪的主要内容,如果未能解决你的问题,请参考以下文章

socket.io 连接在生产中失败,在 localhost 中工作

Ios 应用程序只能在 Intranet 连接中工作

Facebook 分享对话框在哪个 iOS 中工作?

通知突然停止在iOS应用程序中工作

IOS7不认证Gamecenter测试ID;显然在 IO6 中工作正常

如何让指针事件在 iOS 中工作