非法尝试使用共享数据库中的核心数据或默认区域

Illegal attempt to work with the core-data or default zone in the shared database

设置:
我的应用程序使用 CoreData+CloudKit 来镜像 iCloud 内容。
我正在实施记录区域共享并使用 2 iPhones 对其进行测试。 iPhone 1 独立执行应用程序,iPhone 2 在 Xcode 控制下。
当iPhone1个用户邀请iPhone2个用户分享他的记录时,iPhone2个用户可以接受分享。
这会按预期将 iCloud 记录镜像到共享数据库。

问题:
在镜像的时候,我得到了好几倍的日志:

[error] fault: Illegal attempt to work with the core-data or default zone  
in the shared database: <NSSQLCore: 0x105907720>  
(URL: file:///var/mobile/Containers/Data/Application/  
66941553-40FC-4180-928C-BDF85D44AE84/Library/Application%20Support/Shared)  

我不知道什么是非法的,也不知道这种非法尝试会产生什么后果。

有什么想法吗?

编辑 1:
当我启用 运行 时间断点时,应用程序停止在:

Thread 17 Queue : NSManagedObjectContext 0x283f73b50 (serial)  

在:

+[NSCKRecordZoneMetadata zoneMetadataForZoneID:inDatabaseWithScope:forStore:inContext:error:]   

所以好像无法读取用于镜像的iCloud共享数据库区域的元数据。

编辑 2:
再观察一下,如果区域共享处于活动状态并且我在仪表板中查找我的 iCloud 容器:
如果我 select 区域和共享数据库,则会显示 REGULAR_CUSTOM_ZONE 类型的共享区域 com.apple.coredata.cloudkit.zone。如果我点击区域名称,应该会显示区域详细信息。
相反,我收到错误
„BadRequestException:端点不适用于数据库类型“sharedb”“
在我看来,这与我在应用程序中遇到的错误相同。

现在我相信这个错误可以忽略了。
我的应用程序对私有和共享数据库使用 CoreData+CloudKit 镜像。
它现在监控 NSPersistentCloudKitContainer.eventChangedNotification 并按如下方式记录事件:

func printSyncEvent(_ event: NSPersistentCloudKitContainer.Event) {
    let id = event.identifier
    let storeID = event.storeIdentifier
    let eventType: String
    switch event.type {
        case .setup:
            eventType = "setup"
        case .import:
            eventType = "import"
        case .export:
            eventType = "export"
        @unknown default:
            eventType = "unknown"
    }
    let startDate = "\(event.startDate)"
    guard let endDate = event.endDate else {
        print("Event: id: \(id), storeID: \(storeID), type: \(eventType), start: \(startDate)")
        return
    }
    guard event.succeeded else {
        let error = event.error!
        print("Event: id: \(id), storeID: \(storeID), type: \(eventType), start: \(startDate), end: \(endDate), error: \(error)")
        return
    }
    print("Event: id: \(id), storeID: \(storeID), type: \(eventType), start: \(startDate), end: \(endDate)")
}  

示例日志(仅相关部分)如下所示:

PrivateStore: ID = 85D7AF77-64C3-47D6-A30E-06FDD034F6C9
SharedStore: ID = 87582E5F-1F92-4A57-ADEB-E8520190423F

Event: id: 2363CEBA-CF4D-4A10-84A9-6DB0C078C6C0, storeID: 85D7AF77-64C3-47D6-A30E-06FDD034F6C9, type: setup, start: 2022-04-05 09:43:26 +0000
Event: id: 2363CEBA-CF4D-4A10-84A9-6DB0C078C6C0, storeID: 85D7AF77-64C3-47D6-A30E-06FDD034F6C9, type: setup, start: 2022-04-05 09:43:26 +0000, end: 2022-04-05 09:43:27 +0000
Event: id: B0F2EAFE-3FBC-4AAD-B881-DBCCDB1E54E1, storeID: 87582E5F-1F92-4A57-ADEB-E8520190423F, type: setup, start: 2022-04-05 09:43:27 +0000
Event: id: B0F2EAFE-3FBC-4AAD-B881-DBCCDB1E54E1, storeID: 87582E5F-1F92-4A57-ADEB-E8520190423F, type: setup, start: 2022-04-05 09:43:27 +0000, end: 2022-04-05 09:43:27 +0000
Event: id: B5B1577B-671F-4094-914B-BD77C9B9E25B, storeID: 85D7AF77-64C3-47D6-A30E-06FDD034F6C9, type: import, start: 2022-04-05 09:43:27 +0000

Event: id: 7EA39D4B-FC72-428E-AFD3-2C97EFD07D30, storeID: 87582E5F-1F92-4A57-ADEB-E8520190423F, type: import, start: 2022-04-05 09:43:27 +0000
2022-04-05 11:43:28.103640+0200 ShopEasy[50306:2763534] [error] fault: Illegal attempt to work with the core-data or default zone in the shared database: <NSSQLCore: 0x13b021340> (URL: file:///Users/reiner/Library/Developer/CoreSimulator/Devices/0E3AD15A-7079-4BED-82D4-58BB5C26AE61/data/Containers/Data/Application/64189142-A8C8-476D-BD0D-6758E259A100/Library/Application%20Support/Shared)
2022-04-05 11:43:28.103867+0200 ShopEasy[50306:2763534] [error] CoreData: Illegal attempt to work with the core-data or default zone in the shared database: <NSSQLCore: 0x13b021340> (URL: file:///Users/reiner/Library/Developer/CoreSimulator/Devices/0E3AD15A-7079-4BED-82D4-58BB5C26AE61/data/Containers/Data/Application/64189142-A8C8-476D-BD0D-6758E259A100/Library/Application%20Support/Shared)
2022-04-05 11:43:28.108523+0200 ShopEasy[50306:2763534] [error] fault: Illegal attempt to work with the core-data or default zone in the shared database: <NSSQLCore: 0x13b021340> (URL: file:///Users/reiner/Library/Developer/CoreSimulator/Devices/0E3AD15A-7079-4BED-82D4-58BB5C26AE61/data/Containers/Data/Application/64189142-A8C8-476D-BD0D-6758E259A100/Library/Application%20Support/Shared)
2022-04-05 11:43:28.108784+0200 ShopEasy[50306:2763534] [error] CoreData: Illegal attempt to work with the core-data or default zone in the shared database: <NSSQLCore: 0x13b021340> (URL: file:///Users/reiner/Library/Developer/CoreSimulator/Devices/0E3AD15A-7079-4BED-82D4-58BB5C26AE61/data/Containers/Data/Application/64189142-A8C8-476D-BD0D-6758E259A100/Library/Application%20Support/Shared)
Event: id: 7EA39D4B-FC72-428E-AFD3-2C97EFD07D30, storeID: 87582E5F-1F92-4A57-ADEB-E8520190423F, type: import, start: 2022-04-05 09:43:27 +0000, end: 2022-04-05 09:43:28 +0000

Event: id: 2C4409CE-9E46-4F5C-A14E-FF7612FDE3B8, storeID: 87582E5F-1F92-4A57-ADEB-E8520190423F, type: export, start: 2022-04-05 09:43:28 +0000
Event: id: 2C4409CE-9E46-4F5C-A14E-FF7612FDE3B8, storeID: 87582E5F-1F92-4A57-ADEB-E8520190423F, type: export, start: 2022-04-05 09:43:28 +0000, end: 2022-04-05 09:43:28 +0000  

这表明错误是由共享数据库中的导入事件造成的。
有 4 个相同类型的连续错误(非法尝试使用共享数据库中的 core-data 或默认区域),但随后导入完成且没有错误。导入器好像重试了好几次导入才成功。
恐怕我们对此无能为力,只能要求 Apple 不要记录此类错误……