Search results for

“NSPersistentCloudKitContainer”

601 results found

Post

Replies

Boosts

Views

Activity

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 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 macOS to macOS SwiftData iCloud Sync Problems
When using SwiftData + CloudKit integration, which uses NSPersistentCloudKitContainer under the hood, the synchronization typically doesn't happen immediately. To better understand the synchronization, consider going through the following technotes: TN3164: Debugging the synchronization of NSPersistentCloudKitContainer TN3163: Understanding the synchronization of NSPersistentCloudKitContainer TN3162: Understanding CloudKit throttles In your case, the first three bullets are pretty much as-designed. The last one, no edits sync between either Mac, if lasting for ever, which means the synchronization is broken, will be an issue. In that case, you can figure out what happens by capturing and analyzing a sysdiagnose, as described in TN3163. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Feb ’26
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
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.
Dec ’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
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 NSPersistentCloudKitContainer for Shares
NSPersistentCloudKitContainer does not support sharing. Please file a feedback report with your intended sharing use case, data model, and any specific design requirements you have regarding the sharing experience.As others have (correctly) pointed out, NSPersistentCloudKitContainer maintains a specific zone in the private database, and therefore will never see any shared zones owned by other users.You can implement sharing yourself using the standard CKShare / CKRecord APIs.
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’19
Reply to NSPersistentCloudKitContainer for Shares
NSPersistentCloudKitContainer only syncs to a private database, according to the published docs. No mention of public or shared CKDatabase.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jun ’19
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
Replies
6
Boosts
0
Views
1.2k
Activity
Jun ’20
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
Replies
Boosts
Views
Activity
Jun ’25
Reply to macOS to macOS SwiftData iCloud Sync Problems
When using SwiftData + CloudKit integration, which uses NSPersistentCloudKitContainer under the hood, the synchronization typically doesn't happen immediately. To better understand the synchronization, consider going through the following technotes: TN3164: Debugging the synchronization of NSPersistentCloudKitContainer TN3163: Understanding the synchronization of NSPersistentCloudKitContainer TN3162: Understanding CloudKit throttles In your case, the first three bullets are pretty much as-designed. The last one, no edits sync between either Mac, if lasting for ever, which means the synchronization is broken, will be an issue. In that case, you can figure out what happens by capturing and analyzing a sysdiagnose, as described in TN3163. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Feb ’26
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:
Replies
Boosts
Views
Activity
Sep ’22
Reply to Get CKRecord from core data entity
I've found the solution. On the NSPersistentCloudKitContainer we have to simply call persistentContainer.record(for: object.objectID) where object is NSManagedObject
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’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.
Replies
Boosts
Views
Activity
Dec ’25
Reply to Using NSPersistentCloudKitContainer causes crash for iOS 14
My case is exactly like @Michele Longhi's. Except my solution is keeping a singleton of the NSPersistentCloudKitContainer instead of destroying and recreating it multiple times.
Replies
Boosts
Views
Activity
Oct ’20
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.
Replies
Boosts
Views
Activity
Jun ’24
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.
Replies
Boosts
Views
Activity
Feb ’25
Reply to NSPersistentCloudKitContainer sharing with the new databaseScope option
CKDatabase.Scope is also used in other classes, such as CKDatabase. Introducing a new scope class just for NSPersistentCloudKitContainer wouldn't have been a good idea.
Replies
Boosts
Views
Activity
Jun ’20
Reply to SwiftData with shared and private containers
+1 I've built an app using CoreData + CloudKit and now I have to rewrite everything using NSPersistentCloudKitContainer.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’25
Reply to NSPersistentCloudKitContainer not syncing existing data
You will need to migrate your existing core data store with NSPersistentHistoryTrackingKey enabled. This will then allow your old data to be sync'd using NSPersistentCloudKitContainer.
Replies
Boosts
Views
Activity
Jun ’21
Reply to NSPersistentCloudKitContainer for Shares
NSPersistentCloudKitContainer does not support sharing. Please file a feedback report with your intended sharing use case, data model, and any specific design requirements you have regarding the sharing experience.As others have (correctly) pointed out, NSPersistentCloudKitContainer maintains a specific zone in the private database, and therefore will never see any shared zones owned by other users.You can implement sharing yourself using the standard CKShare / CKRecord APIs.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’19
Reply to CloudKit + CoreData: Now how do I take advantage of CloudKit user-to-user sharing without losing CoreData + CloudKit synchronization?
NSPersistentCloudKitContainer does not yet support sharing, please consider filing a feedback request with details about your desired use case.
Replies
Boosts
Views
Activity
Jun ’20