Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

Reply to NSPersistentCloudKitContainer causes crash on watchOS when device is offline
Hi, and thank you for the quick response. It's greatly appreciated! Unfortunately, this crash does not appear to generate a crash log. However, we're able to reproduce it consistently on two separate Apple Watch devices. When using NSPersistentCloudKitContainer and the device is offline (no Wi-Fi and no Bluetooth), the app crashes when entering the background. If we switch to NSPersistentContainer, no crash occurs under the same conditions. If the device is online, no crash occurs, even when using NSPersistentCloudKitContainer and allowing the app to enter the background. If we keep the app in the foreground (e.g., by continuously tapping the screen), the app also does not crash, even when offline and using NSPersistentCloudKitContainer. So in summary, the crash consistently occurs under the following three conditions: Using NSPersistentCloudKitContainer Device is offline (no Wi-Fi, no Bluetooth) App transitions to the background. We would appreciate any insight, particular
Jun ’25
Reply to SwiftData Remote Database Updates
I am not quite clear what you meant by shared remote datastore. If you referred to SwiftData + CloudKit integration enabled with ModelConfiguration.CloudKitDatabase, it is based on NSPersistentCloudKitContainer, and doesn't use the DataStore API. If your intent is to detect the changes NSPersistentCloudKitContainer made on the store and make your fetched result set up to date, you can consider observing .NSPersistentStoreRemoteChange notification, and re-fetch the data in the notification handler. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Jun ’24
NSPersistentCloudKitContainer - CloudKit Error 503 after inserting batch of elements
When I sync my large Core Data database with NSPersistentCloudKitContainer, inserting new rows works well for up to 10k rows. (in batches of ~400 inserts) After that, CloudKit receives a 503 Service Unavailable error with a timeout. Here's the log: CoreData: CloudKit: CoreData+CloudKit: -[PFCloudKitExporter exportIfNecessary]_block_invoke_2(153): : Found 22161 objects needing export. 2021-01-14 11:26:54.985447+0100 [1299:350390] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _exportFinishedWithResult:exporter:](1163): : Export failed with error: The API documentation - https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/CloudKitWebServicesReference/ErrorCodes.html#//apple_ref/doc/uid/TP40015240-CH4-SW1 says 503 means interal server error (try again later) and also says that for throttling the status code would be 429, so I guess it's not rate limiting? I only found that there is a rate limit of 40 requests/second, but since CoreData is doing batch ins
0
0
690
Jan ’21
Reply to Cloudkit not synching across devices after latest ios update
What CloudKit API are you using? If you are using NSPersistentCloudKitContainer, I'd suggest that you start with the following technotes: TN3163: Understanding the synchronization of NSPersistentCloudKitContainer TN3164: Debugging the synchronization of NSPersistentCloudKitContainer If you are using the CloudKit framework, start with: TN3162: Understanding CloudKit throttles The general methodology to debug a CloudKit synchronization issue is to capture and analyze a sysdiagnose, and try to find relevant CloudKit errors from there. If you did find an error and need further discussion, please post the detailed error message here for folks to take a look. In any case, if you believe that CloudKit should be improved in some way, please feel free to provide actionable feedback for the CloudKit folks to consider. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Feb ’25
Reply to How to read/write to App1’s database from App2?
use NSPersistentCloudKitContainerOptions to configure the container identifier to sync with class PersistenceApp1: ObservableObject { static let shared = PersistenceApp1() let container: NSPersistentCloudKitContainer init(…) { container = NSPersistentCloudKitContainer(name: “App1”) let store = NSPersistentStoreDescription() store.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: iCloud.com.example.App1) container = [store] container.loadPersistentStores… } … } Also, make sure to add both container identifiers to your app's Signing & Capabilities > iCloud > Containers list
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’22
NSPersistentCloudKitContainer: Set To-One relation to nil is not synced to CloudKit
Using NSPersistentCloudKitContainer: I have a relation between Item --to-one--> Group. This works fine on device: I can set a Group for an Item and remove the Item from the Group again, everything is persisted locally. The Problem: Adding does work, but removing the Group never appears on a different device. As soon as the Item gets edited on the different device, the Group relation re-appears with the new changes (even if manually removed there as well). What I see in CloudKit dashboard: Group field on Item is of type String. A fresh Item record, never assigned to a Group, does not have the Group field. Removing the Group does not remove the Group field in CloudKit. As soon as it gets a Group field, I can’t get rid of it. Manually emptying the value causes to crash on download. Reproducible with the example project: The behaviour can easily be reproduced with the example project (https://developer.apple.com/documentation/coredata/synchronizing_a_local_store_to_the_cloud?language=objc). Just repla
6
0
1.2k
Jun ’20
Reply to NSPersistentCloudKitContainer data loss edge case
If a user writes changes to the app and the app saves those changes to the Core Data store, they should never be permanently deleted just because iCloud was disabled. It seems quite wrong to me that NSPersistentCloudKitContainer will delete even changes that have not been synced to the cloud. As a developer, what could I do to ensure this does not occur? I believe it is a bad idea to programmatically switch between NSPersistentContainer and NSPersistentCloudKitContainer (discouraged by Apple) and you lose privacy and security.
2w
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
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