Search results for

“NSPersistentCloudKitContainer”

601 results found

Post

Replies

Boosts

Views

Activity

Reply to Setting up push notifications
Hello Steve, After adding the needed capabilities to your project, NSPersistentCloudKitContainer manages the notification configuration to keep your App (local storage) updated with the CloudKit storage. Here - https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit/setting_up_core_data_with_cloudkit you can see the steps to enable the capabilities so your NSPersistentCloudKitContainer can keep your local data updated. Now, keep in mind that the freshness of the data from a Public database is different than from a Private database, NSPersistentCloudKitContainer polls for changes on Application Launch and every 30 minutes, see more detail in this year's WWDC session Sync a Core Data store with the CloudKit public database - min 10:30 - https://developer.apple.com/videos/play/wwdc2020/10650/?t=630. Good luck and feel free to reach out.
Topic: App & System Services SubTopic: General Tags:
Aug ’20
Reply to Specify Parent using NSPersistentCloudKitContainer
As of iOS 14, NSPersistentCloudKitContainer only supports the private database and the public database. If you want your users to be able to share data with others, you need to implement that code manually. Here's a great explanation of how sharing works along with some sample code: https://developer.apple.com/documentation/cloudkit/sharing_cloudkit_data_with_other_icloud_users If you want to share a certain object, you can ask NSPersistentCloudKitContainer for the underlying record using https://developer.apple.com/documentation/coredata/nspersistentcloudkitcontainer/3141668-record. Initialize a new CKShare and set the record as its root record. Retrieve all other records for the hierarchy you'd like to share and set their parent property to the root record (not the share). Then you can save the CKShare using CKModifyRecordsOperation. Please refer to the documentation I've mentioned above to set up a CKDatabaseSubscription and fetch changes from the shared database as. they come in
Jun ’20
NSPersistentCloudKitContainer - Import failed with error: Error Domain=NSCocoaErrorDomain Code=4864
The NSPersistentCloudKitContainer synchronization between core data and iCloud was working fine with phone 15.1. Connected a new iPhone iOS 15.5, it gives error: CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate managedObjectContextSaved:](2504): : Observed context save: - 2022-12-05 13:32:28.377000-0600 r2nr[340:6373] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _importFinishedWithResult:importer:](1245): : Import failed with error: Error Domain=NSCocoaErrorDomain Code=4864 *** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x53, 0x6f, 0x6d, 0x65, 0x20, 0x65, 0x78, 0x61) UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x53, 0x6f, 0x6d, 0x65, 0x20, 0x65, 0x78, 0x61)} CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _importFinishedWithResult:importer:](1245): : Import failed with error: Error Domain=NSCocoaErro
2
0
1.2k
Dec ’22
Reply to SwiftData with shared and private containers
SwiftData + CloudKit public or shared database isn't supported today. If that is critical to your app, I suggest that you file a feedback report to voice your need. The framework, including the new DataStore API, doesn't provide supports in that regard. You can choose to implement your own way, similar to what NSPersistentCloudKitContainer does, but that will be obviously very involved. I'd probably stick with NSPersistentCloudKitContainer, if I do need the integration with CloudKit public or shared database. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’24
Public Database delete records (NSPersistentCloudKitContainer)
As I understood there is no built-in mechanism to propagate deletion operations to other devices automatically (CoreData + CloudKit - public database), in order to delete or simulate a deletion do I have to add an attribute to the entities I create in order to simulate a tombstone? and if so I would never really delete the items? or if I do delete them how would I do it? I watched WWDC20 however is still not clear for me how to implement it
0
0
411
Jun ’23
Reply to SwiftData and CloudKit
The original post had been a year ago, and had run out of my radar since then, until this new post brought this back, thanks to @jenyalebid. If simply creating a SwiftData model container with CloudKit integration, which kicks off the initialization of NSPersistentCloudKitContainer under the hood, causes the hang, I'd suggest that you start with filing an actionable feedback report, because the initialization is not supposed to be a long task. SwiftData + CloudKit integration is based on NSPersistentCloudKitContainer, and so folks can follow the tips described in the following technote to analyze if there is anything goes wrong in the initialization phase: TN3163: Understanding the synchronization of NSPersistentCloudKitContainer If somebody can share a minimal project, with detailed steps, that reproduces the issue, I'd be able to take a look as well. The orignal post does contain a link, but it has been a year, and I am not sure if the issue is the same. Best, —— Ziqiao Chen  Wor
Aug ’25
Reply to CoreData + CloudKit
I'd firstly point you the following technotes, which I believe will give you the whole picture about how Core Data + CloudKit works: TN3163: Understanding the synchronization of NSPersistentCloudKitContainer TN3164: Debugging the synchronization of NSPersistentCloudKitContainer TN3162: Understanding CloudKit throttles Concretely to your questions: What are the solutions I have when the user first loads the app? How to force CoreData to query directly cloudKit? There is no API for an app to speed up the initial synchronization as of today. If there is a lot of data on the server, the synchronization will indeed take long time. I'd suggest that you file a feedback report against that. There is no API to force CoreData to import from CloudKit, and that is as-designed, as discussed in the technotes mentioned above. Does CoreData + CloudKit + NSPersistentCloudKitContainer will download the whole CloudKit database in my local, is that good???? When using NSPersistentCloudKitContainer
Jan ’25
Reply to Setting up push notifications
Hello Steve, After adding the needed capabilities to your project, NSPersistentCloudKitContainer manages the notification configuration to keep your App (local storage) updated with the CloudKit storage. Here - https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit/setting_up_core_data_with_cloudkit you can see the steps to enable the capabilities so your NSPersistentCloudKitContainer can keep your local data updated. Now, keep in mind that the freshness of the data from a Public database is different than from a Private database, NSPersistentCloudKitContainer polls for changes on Application Launch and every 30 minutes, see more detail in this year's WWDC session Sync a Core Data store with the CloudKit public database - min 10:30 - https://developer.apple.com/videos/play/wwdc2020/10650/?t=630. Good luck and feel free to reach out.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’20
Reply to Specify Parent using NSPersistentCloudKitContainer
As of iOS 14, NSPersistentCloudKitContainer only supports the private database and the public database. If you want your users to be able to share data with others, you need to implement that code manually. Here's a great explanation of how sharing works along with some sample code: https://developer.apple.com/documentation/cloudkit/sharing_cloudkit_data_with_other_icloud_users If you want to share a certain object, you can ask NSPersistentCloudKitContainer for the underlying record using https://developer.apple.com/documentation/coredata/nspersistentcloudkitcontainer/3141668-record. Initialize a new CKShare and set the record as its root record. Retrieve all other records for the hierarchy you'd like to share and set their parent property to the root record (not the share). Then you can save the CKShare using CKModifyRecordsOperation. Please refer to the documentation I've mentioned above to set up a CKDatabaseSubscription and fetch changes from the shared database as. they come in
Replies
Boosts
Views
Activity
Jun ’20
Reply to Can the NSPersistentCloudKitContainer mirror the data from the cloudKit public database to the local Core Data if the user is not logged in?
That's worth a feedback report with the full logs. NSPersistentCloudKitContainer is supposed to be compatible with account-less public database use.
Replies
Boosts
Views
Activity
Jun ’24
Reply to Why are my CloudKit Record Types showing "CD_" Prefix ?
This happens automatically when you use NSPersistentCloudKitContainer. See https://developer.apple.com/videos/play/wwdc2019/202/?time=1291 at time 21:30.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’20
NSPersistentCloudKitContainer - Import failed with error: Error Domain=NSCocoaErrorDomain Code=4864
The NSPersistentCloudKitContainer synchronization between core data and iCloud was working fine with phone 15.1. Connected a new iPhone iOS 15.5, it gives error: CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate managedObjectContextSaved:](2504): : Observed context save: - 2022-12-05 13:32:28.377000-0600 r2nr[340:6373] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _importFinishedWithResult:importer:](1245): : Import failed with error: Error Domain=NSCocoaErrorDomain Code=4864 *** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x53, 0x6f, 0x6d, 0x65, 0x20, 0x65, 0x78, 0x61) UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x53, 0x6f, 0x6d, 0x65, 0x20, 0x65, 0x78, 0x61)} CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _importFinishedWithResult:importer:](1245): : Import failed with error: Error Domain=NSCocoaErro
Replies
2
Boosts
0
Views
1.2k
Activity
Dec ’22
Reply to Crash during batch deletion merge when positive fractional decimals are stored and used in a derived attribute
After replacing NSPersistentCloudKitContainer with NSPersistentContainer, I'm still getting the crash, as you suspected. Attached is the crash report when I ran the code on the simulator. BugTest.txt
Replies
Boosts
Views
Activity
Mar ’25
Reply to SwiftData with shared and private containers
SwiftData + CloudKit public or shared database isn't supported today. If that is critical to your app, I suggest that you file a feedback report to voice your need. The framework, including the new DataStore API, doesn't provide supports in that regard. You can choose to implement your own way, similar to what NSPersistentCloudKitContainer does, but that will be obviously very involved. I'd probably stick with NSPersistentCloudKitContainer, if I do need the integration with CloudKit public or shared database. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Public Database delete records (NSPersistentCloudKitContainer)
As I understood there is no built-in mechanism to propagate deletion operations to other devices automatically (CoreData + CloudKit - public database), in order to delete or simulate a deletion do I have to add an attribute to the entities I create in order to simulate a tombstone? and if so I would never really delete the items? or if I do delete them how would I do it? I watched WWDC20 however is still not clear for me how to implement it
Replies
0
Boosts
0
Views
411
Activity
Jun ’23
Reply to How to get NSPersistentCloudKitContainer to sync in background
Please file bugs for sync in widgets. WidgetKit / ExtensionKit do not allow NSPersistentCloudKitContainer to sync today outside your application's process.
Replies
Boosts
Views
Activity
Jun ’21
Reply to SwiftData and CloudKit
The original post had been a year ago, and had run out of my radar since then, until this new post brought this back, thanks to @jenyalebid. If simply creating a SwiftData model container with CloudKit integration, which kicks off the initialization of NSPersistentCloudKitContainer under the hood, causes the hang, I'd suggest that you start with filing an actionable feedback report, because the initialization is not supposed to be a long task. SwiftData + CloudKit integration is based on NSPersistentCloudKitContainer, and so folks can follow the tips described in the following technote to analyze if there is anything goes wrong in the initialization phase: TN3163: Understanding the synchronization of NSPersistentCloudKitContainer If somebody can share a minimal project, with detailed steps, that reproduces the issue, I'd be able to take a look as well. The orignal post does contain a link, but it has been a year, and I am not sure if the issue is the same. Best, —— Ziqiao Chen  Wor
Replies
Boosts
Views
Activity
Aug ’25
Reply to CoreData + CloudKit
I'd firstly point you the following technotes, which I believe will give you the whole picture about how Core Data + CloudKit works: TN3163: Understanding the synchronization of NSPersistentCloudKitContainer TN3164: Debugging the synchronization of NSPersistentCloudKitContainer TN3162: Understanding CloudKit throttles Concretely to your questions: What are the solutions I have when the user first loads the app? How to force CoreData to query directly cloudKit? There is no API for an app to speed up the initial synchronization as of today. If there is a lot of data on the server, the synchronization will indeed take long time. I'd suggest that you file a feedback report against that. There is no API to force CoreData to import from CloudKit, and that is as-designed, as discussed in the technotes mentioned above. Does CoreData + CloudKit + NSPersistentCloudKitContainer will download the whole CloudKit database in my local, is that good???? When using NSPersistentCloudKitContainer
Replies
Boosts
Views
Activity
Jan ’25
Reply to NSPersistentCloudKitContainer: How to re-fetch a record from CloudKit?
No. NSPersistentCloudKitContainer will do this for you after the migration completes. If you have a migration where this doesn't occur file a feedback with your various managed object models and we will investigate.
Replies
Boosts
Views
Activity
Jun ’21
Reply to Check Data Re-Sync on App Reinstall with CloudKit (+SwiftUI)
The data should still be stored in iCloud and NSPersistentCloudKitContainer should take care of downloading data that is in CloudKit. Could you please post the setup of your Core Data stack?
Replies
Boosts
Views
Activity
Jun ’20
Reply to NSPersistentCloudKitContainer Bug
Does Apple read these forums? Or is there a better place to file bugs for their Beta software? It would be nice if we could understand if this was an acknowledged issue with the new release of NSPersistentCloudKitContainer.
Replies
Boosts
Views
Activity
Sep ’21
Reply to CoreData in Multiplatform App
Thanks @nigelfromtewkesbury that worked for me, too. Also led me to persistence.swift:34 where you can change the name of the data model it looks for: container = NSPersistentCloudKitContainer(name: YourContainerName)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’20