Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

NSPersistentCloudKitContainer: Data is gone when turning off iCloud in settings. Reappears when turning it on again.
I am using Core Data with CloudKit through NSPersistentCloudKitContainer. When doing the following, all the data disappears: Start my app (iCloud enabled) Create some items in CoreData Quit the app Turn off iCloud for my app in the iPhone's Settings Start the app again All the items added in step 2 are gone after this. When I turn iCloud on again, they reappear. I read through the documentation, but this does not seem to be expected behaviour. Also, the demo app - https://developer.apple.com/documentation/coredata/synchronizing_a_local_store_to_the_cloud for this topic does not seem to have this issue. However, I am building my CoreData-stack in the same way as they do. Searching on the web it seems that several people have the same issue. Did somebody resolve this? I read that one strategy is to swap NSPersistentCloudKitContainer with NSPersistentContainer in case iCloud is turned off - but the demo-app doesn't do this and still keeps the data even when iCloud gets turned off. So there must
1
0
783
Sep ’20
CloudKit Dashboard logs show no events
I'm using NSPersistentCloudKitContainer in an app and was just studying up on how to do some debugging using the CloudKit Dashboard (watching Build Better Apps with CloudKit Dashboard from WWDC17) - in particular, how to look at live and historical server logs. When I go to CloudKit Dashboard > my.app.bundle.id > Development > Logs and select the Live tab, I see the Logs screen with its header, but instead of showing any log entries, it shows a message saying Logged events will automatically appear here as they happen on the server. If I run my app in development mode (e.g. from Xcode) and update entries, I can see the updated records in CloudKit Dashboard, but the Logs screen stays empty. I can't get CloudKit Dashboard to show any logs at all - live or historical, development or production (yes I know we can't see live production logs, but I get the same blank log area when viewing historical logs for time periods when I know there have been many events). The app is in active development an
6
0
1.8k
Sep ’20
CloudKit's public container can be accessed on wifi, but not on the cellular network
I'm attempting to write to the public container of CloudKit, but I keep getting the error message: CKError 0x281ff9ec0: Network Unavailable (3/NSURLErrorDomain:-1009); The Internet connection appears to be offline. only when I'm accessing the container through the cellular network. When I try on a wifi network, however, it works perfectly fine and can confirm the presence of the uploaded data on the dashboard. There is absolutely nothing wrong with the cellular connectivity of my device. let publicCloudDatabase = CKContainer.default().publicCloudDatabase let operation = CKModifyRecordsOperation(recordsToSave: [exampleRecord], recordIDsToDelete: nil) let operationConfiguration = CKOperation.Configuration() operationConfiguration.allowsCellularAccess = true operationConfiguration.qualityOfService = .userInitiated operation.configuration = operationConfiguration operation.perRecordProgressBlock = {(record, progress) in ttprint(progress) } operation.perRecordCompletionBlock = {(record, error) in ttprint(Upload co
2
0
1.3k
Sep ’20
Cloudkit is broken (sort of) in simulator
I am developing an app that uses NSPersistentCloudKitContainer. I am seeing lots of inconsistency. But....after a long time observing...I strongly believe the simulator implementation of cloudkit is broken. Log in via your icloud Open the built in Apple reminder app in both simulator and on your physical device. You will notice that changes made in simulator propagate reasonably well to the device....but any changes made on device don't propagate to the simulator reminders app...you need to force quit app on simulator for changes to reflect. The ultimate example app is apple notes. It handles sync better than any other app out there. I still am in the process of understanding why my app does not sync as well as notes, eg playing around with things like: container.viewContext.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy container.viewContext.automaticallyMergesChangesFromParent = true NotificationCenter.default.addObserver(self, selector: #selector(storeRemoteChangeNotification), name: NSNotif
0
0
503
Sep ’20
CoreData with CloudKit in WidgetKit not working
In my app, I have an NSPersistentCloudKitContainer set up in the following way: let container: NSPersistentCloudKitContainer init() { self.container = NSPersistentCloudKitContainer(name: Model) self.container.persistentStoreDescriptions[0].setOption( true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey } self.container.loadPersistentStores { (_, error) in guard error == nil else { print(error loading store: (error.debugDescription)) return } } self.container.viewContext.automaticallyMergesChangesFromParent = true } When I invoke a fetch request on the context of the container in my iOS target, it works as expected. However, when I perform the same fetch request in my Widget target, it returns an empty array result. In my iOS target, I have Background Modes / Remote Notifications and iCloud / CloudKit capabilities. In my Widget target, I have the iCloud / CloudKit capability. Not sure why it isn't working, so any help would be much appreciated, thanks!
3
0
1.1k
Sep ’20
NSPersistentCloudKitContainer does not sync in background
I am currently testing the NSPersistentCloudKitContainer. I have strictly followed the guidelines of the new documentation. Basically everything works as desired. I use the option NSPersistentStoreRemoteChangeNotificationPostOptionKey on the description to receive Updates from the remote data store. But the updates from the remote database are only delivered if the app is in the foreground. But I would like to update my widget based on a data change in the backend. Does anyone has an idea how to solve this issues? What i did so far: Background Modes in Capabilities are enabled Push Notifications are enabled i called registerForRemoteNotifications HistoryTracking and RemoteChange Option are enabled on the description of the PersistentStore Syncing works in foreground ✅ Syncing does not work if App is in Background ❌ forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) description?.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) container.viewContext.automaticallyMergesCh
1
0
889
Sep ’20
Using NSPersistentCloudKitContainer causes crash for iOS 14
In iOS 14, I am trying to use the NSPersistentCloudKitContainer, but there is a crash with the following error message: ** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Must register a handler for activity identifier com.apple.coredata.cloudkit.activity.export.[an UUID] before submitting it' terminating with uncaught exception of type CKException Does anyone else have this error? Is there any workaround for this? I have already filled a bug report FB8618522 Thanks in advance!
11
0
3.2k
Sep ’20
Reply to Share an object managed by NSPersistentCloudKitContainer with other users
Hi thank you for making this post. This is really helpful. I have a follow up. There is a 5th point that is missing. What happens when the owner modifies something in the shared document. The other participant can't use private database auto synced with NSPersistentCloudKitContainer because they must use CKContainer.sharedCloudDatabase for shared documents. How to I manually fetch the changes in real time reliability? I saw Maintain a Local Cache For CloudKit Records described here https://developer.apple.com/documentation/cloudkit/sharing_cloudkit_data_with_other_icloud_users but do not understand it. Could you please describe in simpler steps to keep the CKContainer.sharedCloudDatabase synced in real time. Thank you 🙏
Sep ’20
Share an object managed by NSPersistentCloudKitContainer with other users
One question I often see on DevForums and in my day DTS job is if a Core Data object managed by NSPersistentCloudKitContainer can be shared with other iCloud users. The answer is yes but you need to do it using CloudKit API directly because NSPersistentCloudKitContainer doesn’t support CloudKit shared database (CKContainer.sharedCloudDatabase) today. Assuming you have a Core Data object, let’s say a document, that you’d like to collaborate with your colleagues: You are the document owner and can use NSPersistentCloudKitContainer to fully manages the document and synchronize it across your devices. You can grab a CloudKit record associated with your document from NSPersistentCloudKitContainer using record(for:) or recordID(for:), and share it to your colleagues using UICloudSharingController. See our Sharing CloudKit Data with Other iCloud Users - https://developer.apple.com/documentation/cloudkit/sharing_cloudkit_data_with_other_icloud_users sample for how to share a CloudK
2
0
979
Sep ’20
Is it possible to rename Entities after using NSPersistentCloudKitContainer in Core Data?
I've tried using renaming Identifier: 1) Automatic / Lightweight migration seems to fail, because CloudKit integration forbids renaming entities. older devices cannot process these records 2) Tried using just NSPersistentContainer, and the lightweight migration still fails with the above message. NSPersistentCloudKitContainer seems to have marked/tainted the persistent store / SQLite so that renaming of entities is not possible at all. Does anyone know if it is possible to rename entities once you start using NSPersistentCloudKitContainer? (heavyweight migration or such?) Has anyone done this before, in a production app or otherwise?
1
0
1k
Sep ’20
Reply to NSPersistentCloudKitContainer change cloudKitContainerOptions while app is running
I've posted a suggestion for a sync enabled/disabled switch on NSPersistentCloudKitContainer through the feedback tool (FB8571301). This is the reply I got: We do not encourage applications to implement their own sync controls. The user can control the sync state of an application using the iCloud Preferences in the Settings app. The problem is that the iCloud preferences in the settings app are rather hidden.. And there is no way to directly link to this page from my app. There are inherent ownership challenges with toggling between synced and unsynced data. For this reason we recommend using a separate persistent store to hold unsynced data separately from the user’s iCloud data. This is necessarily a heavy-weight operation, the local store must be added and the cloud store removed when the user disables sync. You can customize the persistent store descriptions of a container after it is initialized. For example, you can set the store descriptions on it immediately, which will prevent the default d
Sep ’20
[NSPersistentCloudKitContainer] CloudKit integration forbids renaming 'OldEntityName' to 'NewEntityName'. Older devices can't process the new records. How to proceed?
I used a renaming identifier to rename an Entity Name, but it doesn't seem to work and it causes a crash at start during in-place migration. How to rename an Entity Name when using NSPersistentCloudKitContainer? I get this exception at start: CloudKit integration forbids renaming 'OldEntityName' to 'NewEntityName'. Older devices can't process the new records. Unresolved error Error Domain=NSCocoaErrorDomain Code=134110 An error occurred during persistent store migration. App is not in production, need a way to rename 'OldEntityName' to 'NewEntityName'. How to achieve this?
1
0
916
Sep ’20