Search results for

“NSPersistentCloudKitContainer”

601 results found

Post

Replies

Boosts

Views

Activity

NSPersistentCloudKitContainer support for CloudKit Record Zone Sharing
NSPersistentCloudKitContainer now supports sharing via CloudKit Record Zone Sharing. This new capability allows applications to easily build features that enable sharing of Core Data managed objects with multiple iCloud users. We've updated our sample application and documentation to demonstrate how these new capabilities work. At a high level NSPersistentCloudKitContainer now supports: New API for binding directly to call sites commonly used for sharing in your AppDelegate, UICloudSharingController, or your user interface code. Assigning the .shared database scope to instances of NSPersistentCloudKitContainerOptions Sharing of managed objects to single CKRecordZone Direct access to read or write the CKShare for a managed object via new API on NSPersistentCloudKitContainer. For more information be sure to watch our session Build apps that share data through CloudKit and Core Data on Friday.
1
0
862
Jun ’21
I other any NSPersistentCloudKitContainer event notification exist for iOS 13?
for iOS 14+ there is notification to let you know that your data exported and imported and other events type. `` if let cloudEvent = notification.userInfo?[NSPersistentCloudKitContainer.eventNotificationUserInfoKey] as? NSPersistentCloudKitContainer.Event }`` but to make compatibility my app with iOS 13, if there any event type exist like above for NSPersistentCloudKitContaine?
0
0
1.1k
May ’22
App getting killed by iOS while NSPersistentCloudKitContainer syncs
I have been spending the last several weeks implementing NSPersistentCloudKitContainer in my app, and it is most of the way there. Unfortunately, I keep running into an issue where after several days of successful syncing between devices, each device begins to crash after about a minute of use, repeatedly. The crash report points to a SQL thread doing things with the CoreData and CloudKit frameworks — none of my code whatsoever. It is the typical “CPU: 48 seconds cpu time over 58 seconds (82% cpu average), exceeding limit of 80% cpu over 60 seconds” issue. If I run the devices hooked up to Xcode and debug, I see the thread spin up and the log shows it chugging through changed CKRecords it needs to import, just like normal. If I leave the devices hooked up to Xcode, they eventually make it through this huge job and the devices become usable again. Once one device is in this state, the problem also occurs on new devices trying to download from the cloud for the first time. I’ve attached a screenshot of
9
0
2.7k
Jul ’21
NSPersistentCloudKitContainer: How to re-fetch a record from CloudKit?
Is there a way to ask NSPersistentCloudKitContainer to update a local managed object’s values by refetching them from CloudKit? Here is my scenario: Let’s say I have a simple Address Book app that stores first name, last name, and phone number. I use NSPersisentCloudKitContainer to sync the data across a user’s devices. Let’s say a user installs the app on their iPhone and iPad. They add a bunch of records. All is working well. Now, I create version 2 of the app that adds a Notes field. The user installs version 2 on their iPhone, but have not updated their iPad yet. The user then adds some notes to existing records. Obviously, the user’s iPad will not download these notes since they have not updated to the version of the app that supports that field. Now, when the user finally installs version 2 of the app on their iPad, I want to ask NSPersistentCloudKitContainer to fetch the notes fields for the records that have been updated. However, I don’t see a way to do this. Of course, I could get
1
0
982
Jun ’21
Do unique constraints work on an NSPersistentCloudKitContainer?
The documentation - https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit/creating_a_core_data_model_for_cloudkit for Creating a Core Data Model for CloudKit states that Unique constraints aren’t supported. but I've tried to set one up and it seems to be working fine (locally, I haven't tried syncing yet) on Xcode 11.5 & iOS 13.5. If I'm not mistaken, when NSPersistentCloudKitContainer was first introduced Xcode displayed an error if you tried to add a constraint to an Entity, but that doesn't seem to happen anymore. Has this restriction been lifted or do I just remember it incorrectly and it never showed any errors? If the restriction has not been lifted, does anyone know how to make sure that Entities are not duplicated? It'll be easy to add a cleanup operation after every sync, but so far I am not aware of any way to know when the sync has fully finished - https://developer.apple.com/forums/thread/652607. Thanks.
0
0
690
Jul ’20
NSPersistentCloudKitContainer not syncing data on macOS
Hello, I am using NSPersistentCloudKitContainer to share data between iOS and macOS app.I have set up the project according to the official tutorials. And when I made changes from the macOS app, the lastest data will automatically display on my iOS app. But in the other direction when I made changes on iOS, macOS app will not get the lastest version of the data.I have verified on Cloud Dashboard that the changes made on iOS have been uploaded onto CloudKit server. Just the macOS app and the cloudd process won't create tasks to pull these changes (observed from console.app). And if I quit the macOS app and restart it, lastest data will be pulled.So the problem is that macOS using NSPersistentCloudKitContainer will not get synced data in the runtime.One potential reason is that the official tutorial has mentioned to set the background Remote Notification. I've done this for the iOS app. But for the macOS app, there are no background mode options so I skipped this step.Any ideas to get the sync
4
0
1.3k
Apr ’20
Potential problem with synching users' private CloudKit with NSPersistentCloudKitContainer
Imagine I have a game with new levels every day. Users play my game and their progress is saved in Core Data, which is then synchronized with CloudKit via NSPersistentCloudKitContainer. Users' progress is about 500Kb for each level/day. That's 5 Mb in 10 days. Or 182 Mb in a year. If the user plays my game for a year, gets a new iPhone, and installs my app again — will the NSPersistentCloudKitContainer eventually download all 182 Mb of users' data!?
1
0
714
Jul ’23
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
894
Sep ’20
CKFetchRecordZoneChangesOperation breaks NSPersistentCloudKitContainer when called inside AppDelegate?
I'm trying to call CKFetchRecordZoneChangesOperation to get the latest changes from the shared database.But when I run that operation from inside didFinishLaunchingWithOptions, NSPersistentCloudKitContainer will break. It will save to coredata, but it will no longer sync to Cloudkit. It's as if it's paused. When I restart the app, the sync resumes.But if I call CKFetchRecordZoneChangesOperation later in the app lifecycle, say in viewDidLoad, everything works fine. Why is this?
1
0
654
Feb ’20
How to sync NSPersistentCloudKitContainer in background after performing AppIntent from widget
I have an app that uses NSPersistentCloudKitContainer and a widget that displays a record. I want to add a button with interactive widgets in iOS 17 to modify the visible record via an AppIntent. When I do this the app logs: CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate managedObjectContextSaved:](2945): : Observed context save: - It does not automatically sync this change to iCloud, not until I manually return the app to the foreground, even if I delay returning from the perform() function. Is there a way to sync NSPersistentCloudKitContainer while the app is in the background as a result of this change triggered in the widget? Thanks!
2
0
920
Jul ’23
NSPersistentCloudKitContainer CKRecord conversion errors
I'm using NSPersistentCloudKitContainer with my app and everything has been working fine for the most part. However, every now and then I come across an entity that saves fine into core data but then can't sync to cloud kit and causes the entire cloud kit feature to stop working. The error happens when starting the app and looks like this: error: CoreData+CloudKit: -NSCloudKitMirroringDelegate _requestAbortedNotInitialized:: - Never successfully initialized and cannot execute request ' 3CD51F2A-E632-4FF0-8B8C-C17DCB15A002' due to error: ... 3 Batch Request Failed CKError's omited ... }> The app is for keeping track of Books, so the basic data model is an entity named Book with a relationship named imageData. This maps to an entity named ImageData with a field named data. data is of type binary data and where the cover image for a particular book is stored. This has worked so far for hundreds of entries into core data and cloud kit, but every now and then I see an error like this in the console a
4
0
1.3k
Jul ’23
How to get NSPersistentCloudKitContainer to sync in background
Is it possible for an app using NSPersistentCloudKitContainer to enable sync in the background, if so, how? Install app on your iPhone and iPad, create some data, it automatically syncs to both and life is good Close the iPad app Modify the data on iPhone Desired behavior: The backgrounded iPad app should sync (even if it takes a while) and be informed that its local database has finished syncing or similarly that changes were made. The use case is I want to reload my widget when data changes so it's up-to-date, so I need my app to sync it in the background, then notify when it's complete to be able to trigger the widget reload. I am concerned it will be a poor widget experience if it's always showing stale data until they manually open the app to initiate sync - kind of defeats the purpose of widgets. ha According to this post, they found sync is never run in the background. Is this not the case, or has it changed in iOS 15? Thanks!
2
0
1.7k
Jun ’21
How to migrate NSPersistentCloudKitContainer to App Group to access in Widget
I have shipped an app that utilizes Core Data in CloudKit viaNSPersistentCloudKitContainer. I now want to add a widget that can query for the current data to display. It's my understanding you need to migrate this to a new location available to a shared App Group. How do you do this? container = NSPersistentCloudKitContainer(name: AppName) container.loadPersistentStores { description, error in //handle error } container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy container.viewContext.automaticallyMergesChangesFromParent = true
1
0
1.4k
Jun ’21
NSPersistentCloudKitContainer support for CloudKit Record Zone Sharing
NSPersistentCloudKitContainer now supports sharing via CloudKit Record Zone Sharing. This new capability allows applications to easily build features that enable sharing of Core Data managed objects with multiple iCloud users. We've updated our sample application and documentation to demonstrate how these new capabilities work. At a high level NSPersistentCloudKitContainer now supports: New API for binding directly to call sites commonly used for sharing in your AppDelegate, UICloudSharingController, or your user interface code. Assigning the .shared database scope to instances of NSPersistentCloudKitContainerOptions Sharing of managed objects to single CKRecordZone Direct access to read or write the CKShare for a managed object via new API on NSPersistentCloudKitContainer. For more information be sure to watch our session Build apps that share data through CloudKit and Core Data on Friday.
Replies
1
Boosts
0
Views
862
Activity
Jun ’21
I other any NSPersistentCloudKitContainer event notification exist for iOS 13?
for iOS 14+ there is notification to let you know that your data exported and imported and other events type. `` if let cloudEvent = notification.userInfo?[NSPersistentCloudKitContainer.eventNotificationUserInfoKey] as? NSPersistentCloudKitContainer.Event }`` but to make compatibility my app with iOS 13, if there any event type exist like above for NSPersistentCloudKitContaine?
Replies
0
Boosts
0
Views
1.1k
Activity
May ’22
App getting killed by iOS while NSPersistentCloudKitContainer syncs
I have been spending the last several weeks implementing NSPersistentCloudKitContainer in my app, and it is most of the way there. Unfortunately, I keep running into an issue where after several days of successful syncing between devices, each device begins to crash after about a minute of use, repeatedly. The crash report points to a SQL thread doing things with the CoreData and CloudKit frameworks — none of my code whatsoever. It is the typical “CPU: 48 seconds cpu time over 58 seconds (82% cpu average), exceeding limit of 80% cpu over 60 seconds” issue. If I run the devices hooked up to Xcode and debug, I see the thread spin up and the log shows it chugging through changed CKRecords it needs to import, just like normal. If I leave the devices hooked up to Xcode, they eventually make it through this huge job and the devices become usable again. Once one device is in this state, the problem also occurs on new devices trying to download from the cloud for the first time. I’ve attached a screenshot of
Replies
9
Boosts
0
Views
2.7k
Activity
Jul ’21
NSPersistentCloudKitContainer: How to re-fetch a record from CloudKit?
Is there a way to ask NSPersistentCloudKitContainer to update a local managed object’s values by refetching them from CloudKit? Here is my scenario: Let’s say I have a simple Address Book app that stores first name, last name, and phone number. I use NSPersisentCloudKitContainer to sync the data across a user’s devices. Let’s say a user installs the app on their iPhone and iPad. They add a bunch of records. All is working well. Now, I create version 2 of the app that adds a Notes field. The user installs version 2 on their iPhone, but have not updated their iPad yet. The user then adds some notes to existing records. Obviously, the user’s iPad will not download these notes since they have not updated to the version of the app that supports that field. Now, when the user finally installs version 2 of the app on their iPad, I want to ask NSPersistentCloudKitContainer to fetch the notes fields for the records that have been updated. However, I don’t see a way to do this. Of course, I could get
Replies
1
Boosts
0
Views
982
Activity
Jun ’21
Do unique constraints work on an NSPersistentCloudKitContainer?
The documentation - https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit/creating_a_core_data_model_for_cloudkit for Creating a Core Data Model for CloudKit states that Unique constraints aren’t supported. but I've tried to set one up and it seems to be working fine (locally, I haven't tried syncing yet) on Xcode 11.5 & iOS 13.5. If I'm not mistaken, when NSPersistentCloudKitContainer was first introduced Xcode displayed an error if you tried to add a constraint to an Entity, but that doesn't seem to happen anymore. Has this restriction been lifted or do I just remember it incorrectly and it never showed any errors? If the restriction has not been lifted, does anyone know how to make sure that Entities are not duplicated? It'll be easy to add a cleanup operation after every sync, but so far I am not aware of any way to know when the sync has fully finished - https://developer.apple.com/forums/thread/652607. Thanks.
Replies
0
Boosts
0
Views
690
Activity
Jul ’20
NSPersistentCloudKitContainer not syncing data on macOS
Hello, I am using NSPersistentCloudKitContainer to share data between iOS and macOS app.I have set up the project according to the official tutorials. And when I made changes from the macOS app, the lastest data will automatically display on my iOS app. But in the other direction when I made changes on iOS, macOS app will not get the lastest version of the data.I have verified on Cloud Dashboard that the changes made on iOS have been uploaded onto CloudKit server. Just the macOS app and the cloudd process won't create tasks to pull these changes (observed from console.app). And if I quit the macOS app and restart it, lastest data will be pulled.So the problem is that macOS using NSPersistentCloudKitContainer will not get synced data in the runtime.One potential reason is that the official tutorial has mentioned to set the background Remote Notification. I've done this for the iOS app. But for the macOS app, there are no background mode options so I skipped this step.Any ideas to get the sync
Replies
4
Boosts
0
Views
1.3k
Activity
Apr ’20
Potential problem with synching users' private CloudKit with NSPersistentCloudKitContainer
Imagine I have a game with new levels every day. Users play my game and their progress is saved in Core Data, which is then synchronized with CloudKit via NSPersistentCloudKitContainer. Users' progress is about 500Kb for each level/day. That's 5 Mb in 10 days. Or 182 Mb in a year. If the user plays my game for a year, gets a new iPhone, and installs my app again — will the NSPersistentCloudKitContainer eventually download all 182 Mb of users' data!?
Replies
1
Boosts
0
Views
714
Activity
Jul ’23
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
Replies
1
Boosts
0
Views
894
Activity
Sep ’20
NSPersistentCloudKitContainer trigger sync manually for testing in Simulator
Hi,is there a way to ask NSPersistentCloudKitContainer to refresh/look for remote changes manually?While it would be great if push notifications would work in the simulator so syncing can be tested without multiple actual devices it would be helpful to have a way to manually request a refresh.Greetings,Ralf
Replies
1
Boosts
0
Views
849
Activity
Sep ’19
CKFetchRecordZoneChangesOperation breaks NSPersistentCloudKitContainer when called inside AppDelegate?
I'm trying to call CKFetchRecordZoneChangesOperation to get the latest changes from the shared database.But when I run that operation from inside didFinishLaunchingWithOptions, NSPersistentCloudKitContainer will break. It will save to coredata, but it will no longer sync to Cloudkit. It's as if it's paused. When I restart the app, the sync resumes.But if I call CKFetchRecordZoneChangesOperation later in the app lifecycle, say in viewDidLoad, everything works fine. Why is this?
Replies
1
Boosts
0
Views
654
Activity
Feb ’20
How to sync NSPersistentCloudKitContainer in background after performing AppIntent from widget
I have an app that uses NSPersistentCloudKitContainer and a widget that displays a record. I want to add a button with interactive widgets in iOS 17 to modify the visible record via an AppIntent. When I do this the app logs: CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate managedObjectContextSaved:](2945): : Observed context save: - It does not automatically sync this change to iCloud, not until I manually return the app to the foreground, even if I delay returning from the perform() function. Is there a way to sync NSPersistentCloudKitContainer while the app is in the background as a result of this change triggered in the widget? Thanks!
Replies
2
Boosts
0
Views
920
Activity
Jul ’23
NSPersistentCloudKitContainer CKRecord conversion errors
I'm using NSPersistentCloudKitContainer with my app and everything has been working fine for the most part. However, every now and then I come across an entity that saves fine into core data but then can't sync to cloud kit and causes the entire cloud kit feature to stop working. The error happens when starting the app and looks like this: error: CoreData+CloudKit: -NSCloudKitMirroringDelegate _requestAbortedNotInitialized:: - Never successfully initialized and cannot execute request ' 3CD51F2A-E632-4FF0-8B8C-C17DCB15A002' due to error: ... 3 Batch Request Failed CKError's omited ... }> The app is for keeping track of Books, so the basic data model is an entity named Book with a relationship named imageData. This maps to an entity named ImageData with a field named data. data is of type binary data and where the cover image for a particular book is stored. This has worked so far for hundreds of entries into core data and cloud kit, but every now and then I see an error like this in the console a
Replies
4
Boosts
0
Views
1.3k
Activity
Jul ’23
Reply to Using iCloud Integration for Core Data with SwiftUI App Protocol
You can use this approach https://developer.apple.com/forums/thread/650876 and then use the NSPersistentCloudKitContainer instead of NSPersistentContainer. A good explanation of how to integrate the NSPersistentCloudKitContainer properly is here: andrewcbancroft.com/blog/ios-development/data-persistence/getting-started-with-nspersistentcloudkitcontainer/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’20
How to get NSPersistentCloudKitContainer to sync in background
Is it possible for an app using NSPersistentCloudKitContainer to enable sync in the background, if so, how? Install app on your iPhone and iPad, create some data, it automatically syncs to both and life is good Close the iPad app Modify the data on iPhone Desired behavior: The backgrounded iPad app should sync (even if it takes a while) and be informed that its local database has finished syncing or similarly that changes were made. The use case is I want to reload my widget when data changes so it's up-to-date, so I need my app to sync it in the background, then notify when it's complete to be able to trigger the widget reload. I am concerned it will be a poor widget experience if it's always showing stale data until they manually open the app to initiate sync - kind of defeats the purpose of widgets. ha According to this post, they found sync is never run in the background. Is this not the case, or has it changed in iOS 15? Thanks!
Replies
2
Boosts
0
Views
1.7k
Activity
Jun ’21
How to migrate NSPersistentCloudKitContainer to App Group to access in Widget
I have shipped an app that utilizes Core Data in CloudKit viaNSPersistentCloudKitContainer. I now want to add a widget that can query for the current data to display. It's my understanding you need to migrate this to a new location available to a shared App Group. How do you do this? container = NSPersistentCloudKitContainer(name: AppName) container.loadPersistentStores { description, error in //handle error } container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy container.viewContext.automaticallyMergesChangesFromParent = true
Replies
1
Boosts
0
Views
1.4k
Activity
Jun ’21