Search results for

“NSPersistentCloudKitContainer”

602 results found

Post

Replies

Boosts

Views

Activity

Core Data and CloudKit integration issue when renaming relationship (code 134110)
I currently have an app using Core Data in the App Store: the app allows people to record their water and sailing activities (think of it like Strava for sailors). I have not updated the app for 3 years, the app seems to be still working fine on latest iOS versions but I recently planned to improve the app. I am currently working on an update for this app, and need to change the data model and schema. I would like to have an automatic lightweight migration. I renamed some entities, properties and relationships, but I made sure to put the previous ids in the Renaming ID field in the editor. I want to take advantage of the opportunity to sync the updated schema on CloudKit. I followed the instruction on Apple Developer documentation to setup the sync. I also made sure to initialize the schema using initializeCloudKitSchema(). When I visit the dashboard, I see the correct schema. The container is only in development mode, not pushed into production. When I launch the app with a sqlite file generated by the avail
0
0
965
Oct ’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
511
Sep ’20
NSPersistentCloudKitContainer and Persistent History Tracking
I'm using Core Data and CloudKit together, and so far everything looks great. But one thing that I haven't been able to find much literature on is the interaction between NSPersistentCloudKitContainer and Persistent History Tracking. My assumption is that NSPersistentCloudKitContainer leans on Persistent History Tracking to execute its responsibilities. So if we're using Persistent History Tracking elsewhere – maybe to update an app extension using a process similar to the one outlined at https://www.avanderlee.com/swift/persistent-history-tracking-core-data/ – there's a risk of interrupting that process. Especially with regards to executing a NSPersistentHistoryChangeRequest.deleteHistory(before:) request. Would this run the risk of deleting history that NSPersistentCloudKitContainer requires to perform its roles? Is there a way to synchronise these various responsibilities?
0
0
812
Aug ’21
Heavyweight Core Data migration with NSPersistentCloudKitContainer
I'm looking for a solution for the next situation: My app uses CoreData with CloudKit mirroring (via NSPersistentCloudKitContainer). In the latest version of my app I made some changes in db schema and created heavyweight core data migration for it. After this migration finishes, I see lots of duplicates for my entities. I think that CloudKit sees migrated container as a completely new one and just tries to download everything from iCloud again. So generally the question is: should I clean my old CloudKit container somehow and just copy all the data from the new, migrated local one, or there is another solution, how to update cloud kit data with new migrated entities? I'm sorry, if this question is stupid, I'm new to cloud kit and used it in totally auto mode, by just replacing NSPersistentContainer with NSPersistentCloudKitContainer (please, see the code here - https://gist.github.com/eiskrenkov/228c6ecb5c1b78ba360838114a7d0911 ), but now this issue happened. Any help, or chunk of code will
0
0
589
Oct ’20
NSPersistentCloudKitContainer with CKAsset?
Trying to figure out the best way to update an CoreData app to use Cloud Kit.Right now I have a ObjectA entity defined as the top level object. There is a Photo entity that contains a Binary Data attribute for the thumbnail and a URI for the location of the full image. So bascially that setup is a lot like a CKAsset in CloudKit and CKAsset would seem to be the logical way to get the images to sync between devices.I can't find anything along those lines relating to NSPersistentCloudKitContainer though. As the model is taken from Core Data model you can't really predefine an asset attribute. So would the approach be to get the CKRecord and directly add the CKAsset that way? Would there be repercussions related to the Container if you did that?And if there is some simpler way I am missing please let me know. I am aware I can do a Binary Data attribute, I had done that earlier in the app's life and it didn't work as well as just providing the URI for the image and managing the data myself. Or would that
0
0
739
Aug ’19
Sync for the first time the CloudKit data
My app backup the data to iCloud or sync with user device through the user iCloud account using NSPersistentCloudKitContainer privateDataBase. The main problem is, when user install the app I need to know if user has data in iCloud or not according this information, I let user to setup account or fetch the existing account, since it takes too long to fetch with local CoreData, I am trying to find a way to fetch directly from iCloud through CloudKit, since I am new in CloudKit, I don't know how to fetch data from CloudKit any help appreciate.
0
0
738
May ’22
iCloud Sync NSPersistentCloudKitContainer: Make use of BGProcessingTaskRequest to catch up?
Hi, I have implemented iCloud Sync using NSPersistentCloudKitContainer. However, I have a lot of data to sync in my use case which can take quite some time (minutes) especially when starting with a new device (10's of minutes). I was wondering if there is a way to make good use of BGProcessingTaskRequest (ie long running task over night, potentially with requiresExternalPower). The idea is to let the device catch up with the remote store during such a long running background task over night/during charge. I already tried to hack my way into this by trying to just listen to sync events during the task and not finish the task until sync events have stopped but it seems the sync processor does have its own awareness of the app moving to the background and therefore might not even wake up during the background task. Any idea how I can help the CloudKitContainer to catch up in the background with very large workloads? Thanks!
0
0
637
May ’22
Mistake about CKReference in Using Core Data With CloudKit (WWDC 2019)
The presenter says you might be wondering why we don't do this with CKReference instead. And that's because CKReference has some limitations that we don't think work well for Core Data clients. Namely that it's limited to 750 total objects. However, that isn't correct, the 750 limit is only for references that have a delete action: https://developer.apple.com/documentation/cloudkit/ckrecord/reference Important There is a hard limit to the number of references with a CKRecord.ReferenceAction.deleteSelf action that any one record can have. This limit is 750 references, and any attempt to exceed it results in an error from the server. This is why the Notes app has no issue with more than 750 note records with a reference to a folder record. I really wish NSPersistentCloudKitContainer had used CKReference and also that _CKReferenceActionValidate was made public. CKShare has limitations too, yet it used that and there was no custom sharing done like custom references were done.
0
0
877
May ’22
Using Core Data With CloudKit
Hi, I have NSPersistentCloudKitContainer and everything is great until I faced the issue after a while of using it. It takes so long to sync because its loading all the changes that was done on the object and doesn't just fetch the latest values of the object. My solution now is to manually fetch CKRecords to see if there is something or not. If so I'm displaying Loading while CoreData and CloudKit find their way to sync. Thanks
0
0
567
Apr ’21
Implementing an iCloud on off button in SwiftUI results in crash
I've added iCloud into my SwiftUI app and everything seems to be working great, however I need to implement an on off toggle for it. After searching, I found a couple forums posts that suggested to re-create the container when icloud is toggled on off. Here's the code: lazy var persistentContainer: NSPersistentContainer = { ttreturn setupContainer() }() /* This is called when the iCloud setting is turned on and off */ func refreshCoreDataContainer() { tt/* Save changes before reloading */ tttry? self.persistentContainer.viewContext.save() tt/* Reload the container */ ttself.persistentContainer = self.setupContainer() } private func setupContainer() -> NSPersistentContainer { ttlet useCloudSync = UserSettings.shared.enableiCloudSync ttlet container: NSPersistentContainer! tt/* Use the icloud container if the user enables icloud, otherwise use the regular container */ ttif useCloudSync { ttttcontainer = NSPersistentCloudKitContainer(name: App) tt} else { ttttcontainer = NSPersistentContainer(name: A
0
0
1.1k
Nov ’20
CloudKit Synchronized "User Defaults"
I have a CoreData-based application, set up with a private CloudKit container and using NSPersistentCloudKitContainer. However, I need additional CloudKit-synchronized data that lives in this container, but not as part of a CoreData scheme. (I.e., I need to read/write some data to the CloudKit container BEFORE initializing the NSPersistentCloudKitContainer. (1) Is this possible? [I'm assuming that the answer is YES.] (2) Since I'm a complete neophyte with CloudKit, can you give me some guidance as to how to set this all up? One way to think about what I want to do is to create a cloud-synchronized UserDefaults that provides consistent default data to all of a user's devices.
0
0
913
Jun ’21
Changing relationship delete rule & CloudKit
Hi, any side effect to be aware of when changing a core data relationship delete rule from Null to Cascade? I NSPersistentCloudKitContainer to handle CloudKit sync in case that's relevant. It doesn't look like any migration is required, and the cloudkit schema doesn't change so it seems there's nothing to do on the cloudkit-side either. However I'd prefer to double check to avoid making false assumptions. I wasn't able to find any documentation on that particular point so if someone can shade some light on how things work under the hood that would be appreciated. Thanks!
0
0
918
Jun ’22
Core Data and CloudKit integration issue when renaming relationship (code 134110)
I currently have an app using Core Data in the App Store: the app allows people to record their water and sailing activities (think of it like Strava for sailors). I have not updated the app for 3 years, the app seems to be still working fine on latest iOS versions but I recently planned to improve the app. I am currently working on an update for this app, and need to change the data model and schema. I would like to have an automatic lightweight migration. I renamed some entities, properties and relationships, but I made sure to put the previous ids in the Renaming ID field in the editor. I want to take advantage of the opportunity to sync the updated schema on CloudKit. I followed the instruction on Apple Developer documentation to setup the sync. I also made sure to initialize the schema using initializeCloudKitSchema(). When I visit the dashboard, I see the correct schema. The container is only in development mode, not pushed into production. When I launch the app with a sqlite file generated by the avail
Replies
0
Boosts
0
Views
965
Activity
Oct ’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
Replies
0
Boosts
0
Views
511
Activity
Sep ’20
NSPersistentCloudKitContainer and Persistent History Tracking
I'm using Core Data and CloudKit together, and so far everything looks great. But one thing that I haven't been able to find much literature on is the interaction between NSPersistentCloudKitContainer and Persistent History Tracking. My assumption is that NSPersistentCloudKitContainer leans on Persistent History Tracking to execute its responsibilities. So if we're using Persistent History Tracking elsewhere – maybe to update an app extension using a process similar to the one outlined at https://www.avanderlee.com/swift/persistent-history-tracking-core-data/ – there's a risk of interrupting that process. Especially with regards to executing a NSPersistentHistoryChangeRequest.deleteHistory(before:) request. Would this run the risk of deleting history that NSPersistentCloudKitContainer requires to perform its roles? Is there a way to synchronise these various responsibilities?
Replies
0
Boosts
0
Views
812
Activity
Aug ’21
Heavyweight Core Data migration with NSPersistentCloudKitContainer
I'm looking for a solution for the next situation: My app uses CoreData with CloudKit mirroring (via NSPersistentCloudKitContainer). In the latest version of my app I made some changes in db schema and created heavyweight core data migration for it. After this migration finishes, I see lots of duplicates for my entities. I think that CloudKit sees migrated container as a completely new one and just tries to download everything from iCloud again. So generally the question is: should I clean my old CloudKit container somehow and just copy all the data from the new, migrated local one, or there is another solution, how to update cloud kit data with new migrated entities? I'm sorry, if this question is stupid, I'm new to cloud kit and used it in totally auto mode, by just replacing NSPersistentContainer with NSPersistentCloudKitContainer (please, see the code here - https://gist.github.com/eiskrenkov/228c6ecb5c1b78ba360838114a7d0911 ), but now this issue happened. Any help, or chunk of code will
Replies
0
Boosts
0
Views
589
Activity
Oct ’20
Sharing app data with NSPersistentCloudKitContainer and keyboard extensions no go?
Am I wrong or is it not possible to share Core Data+CloudKit with a keyboard extension? It works if I set an app group but then I lose the CloudKit sync feature, which is not acceptable for me. Is there some other way to share the data while keeping sync?
Replies
0
Boosts
0
Views
713
Activity
Aug ’21
NSPersistentCloudKitContainer with CKAsset?
Trying to figure out the best way to update an CoreData app to use Cloud Kit.Right now I have a ObjectA entity defined as the top level object. There is a Photo entity that contains a Binary Data attribute for the thumbnail and a URI for the location of the full image. So bascially that setup is a lot like a CKAsset in CloudKit and CKAsset would seem to be the logical way to get the images to sync between devices.I can't find anything along those lines relating to NSPersistentCloudKitContainer though. As the model is taken from Core Data model you can't really predefine an asset attribute. So would the approach be to get the CKRecord and directly add the CKAsset that way? Would there be repercussions related to the Container if you did that?And if there is some simpler way I am missing please let me know. I am aware I can do a Binary Data attribute, I had done that earlier in the app's life and it didn't work as well as just providing the URI for the image and managing the data myself. Or would that
Replies
0
Boosts
0
Views
739
Activity
Aug ’19
Sync for the first time the CloudKit data
My app backup the data to iCloud or sync with user device through the user iCloud account using NSPersistentCloudKitContainer privateDataBase. The main problem is, when user install the app I need to know if user has data in iCloud or not according this information, I let user to setup account or fetch the existing account, since it takes too long to fetch with local CoreData, I am trying to find a way to fetch directly from iCloud through CloudKit, since I am new in CloudKit, I don't know how to fetch data from CloudKit any help appreciate.
Replies
0
Boosts
0
Views
738
Activity
May ’22
iCloud Sync NSPersistentCloudKitContainer: Make use of BGProcessingTaskRequest to catch up?
Hi, I have implemented iCloud Sync using NSPersistentCloudKitContainer. However, I have a lot of data to sync in my use case which can take quite some time (minutes) especially when starting with a new device (10's of minutes). I was wondering if there is a way to make good use of BGProcessingTaskRequest (ie long running task over night, potentially with requiresExternalPower). The idea is to let the device catch up with the remote store during such a long running background task over night/during charge. I already tried to hack my way into this by trying to just listen to sync events during the task and not finish the task until sync events have stopped but it seems the sync processor does have its own awareness of the app moving to the background and therefore might not even wake up during the background task. Any idea how I can help the CloudKitContainer to catch up in the background with very large workloads? Thanks!
Replies
0
Boosts
0
Views
637
Activity
May ’22
Mistake about CKReference in Using Core Data With CloudKit (WWDC 2019)
The presenter says you might be wondering why we don't do this with CKReference instead. And that's because CKReference has some limitations that we don't think work well for Core Data clients. Namely that it's limited to 750 total objects. However, that isn't correct, the 750 limit is only for references that have a delete action: https://developer.apple.com/documentation/cloudkit/ckrecord/reference Important There is a hard limit to the number of references with a CKRecord.ReferenceAction.deleteSelf action that any one record can have. This limit is 750 references, and any attempt to exceed it results in an error from the server. This is why the Notes app has no issue with more than 750 note records with a reference to a folder record. I really wish NSPersistentCloudKitContainer had used CKReference and also that _CKReferenceActionValidate was made public. CKShare has limitations too, yet it used that and there was no custom sharing done like custom references were done.
Replies
0
Boosts
0
Views
877
Activity
May ’22
Can I fire NSPersistentCloudKitContainer update manually?
Can I fire NSPersistentCloudKitContainer update manually? I want to schedule data sending event for server after unrestricting CloudKit restriction by CloudKit Web Service API.
Replies
0
Boosts
0
Views
774
Activity
Mar ’21
Using Core Data With CloudKit
Hi, I have NSPersistentCloudKitContainer and everything is great until I faced the issue after a while of using it. It takes so long to sync because its loading all the changes that was done on the object and doesn't just fetch the latest values of the object. My solution now is to manually fetch CKRecords to see if there is something or not. If so I'm displaying Loading while CoreData and CloudKit find their way to sync. Thanks
Replies
0
Boosts
0
Views
567
Activity
Apr ’21
Implementing an iCloud on off button in SwiftUI results in crash
I've added iCloud into my SwiftUI app and everything seems to be working great, however I need to implement an on off toggle for it. After searching, I found a couple forums posts that suggested to re-create the container when icloud is toggled on off. Here's the code: lazy var persistentContainer: NSPersistentContainer = { ttreturn setupContainer() }() /* This is called when the iCloud setting is turned on and off */ func refreshCoreDataContainer() { tt/* Save changes before reloading */ tttry? self.persistentContainer.viewContext.save() tt/* Reload the container */ ttself.persistentContainer = self.setupContainer() } private func setupContainer() -> NSPersistentContainer { ttlet useCloudSync = UserSettings.shared.enableiCloudSync ttlet container: NSPersistentContainer! tt/* Use the icloud container if the user enables icloud, otherwise use the regular container */ ttif useCloudSync { ttttcontainer = NSPersistentCloudKitContainer(name: App) tt} else { ttttcontainer = NSPersistentContainer(name: A
Replies
0
Boosts
0
Views
1.1k
Activity
Nov ’20
CloudKit Synchronized "User Defaults"
I have a CoreData-based application, set up with a private CloudKit container and using NSPersistentCloudKitContainer. However, I need additional CloudKit-synchronized data that lives in this container, but not as part of a CoreData scheme. (I.e., I need to read/write some data to the CloudKit container BEFORE initializing the NSPersistentCloudKitContainer. (1) Is this possible? [I'm assuming that the answer is YES.] (2) Since I'm a complete neophyte with CloudKit, can you give me some guidance as to how to set this all up? One way to think about what I want to do is to create a cloud-synchronized UserDefaults that provides consistent default data to all of a user's devices.
Replies
0
Boosts
0
Views
913
Activity
Jun ’21
Changing relationship delete rule & CloudKit
Hi, any side effect to be aware of when changing a core data relationship delete rule from Null to Cascade? I NSPersistentCloudKitContainer to handle CloudKit sync in case that's relevant. It doesn't look like any migration is required, and the cloudkit schema doesn't change so it seems there's nothing to do on the cloudkit-side either. However I'd prefer to double check to avoid making false assumptions. I wasn't able to find any documentation on that particular point so if someone can shade some light on how things work under the hood that would be appreciated. Thanks!
Replies
0
Boosts
0
Views
918
Activity
Jun ’22
NSPersistentCloudKitContainer: Cocoa error 134420
Some of my users are experiencing synchronization issues when using the NSPersistentCloudKitContainer in CoreData. This error only occurs in Apple Watch so far. I can not find any documents about this error. Does anyone know what this error code means?
Replies
0
Boosts
0
Views
557
Activity
Jun ’22