Search results for

“NSPersistentCloudKitContainer”

601 results found

Post

Replies

Boosts

Views

Activity

Reply to Is it safe to use a NSPersistentCloudKitContainer on a Share Extension?
Having used this API for two of my apps, and speaking with an Apple engineer, it sounds like we can assume the following: NSPersistentCloudKitContainer can be safely used in a Share Extension for storing data locally. It will complete the save operation locally. Uploading to CloudKit requires a scheduled background operation on the part of the API. Because of this, by the time the Extension is terminated, the background operation is not completed, and thus the CloudKit sync does not occur. In my testing, this leads to predictable behavior: Data is never uploaded from an Extension, however, Data is saved locally in your persistent container. And upon launching your app, with the container alive once more, it will sync your data to CloudKit. It's a bit unwieldy having to launch your app after an operation in an Extension, but from my own usage, I think it's safe to say that you can safely use NSPersistentCloudKitContainer, even if it doesn't sync as you or I would like. I truly hope this behav
Topic: App & System Services SubTopic: Core OS Tags:
Apr ’21
Saving and fetching to Core Data
I am trying to save to Core Data so when the App is reopened the data will be there. I have a single ViewController, within that VC I have 10 Text Fields which the user inputs their data (numbers). I have a function where I add all the data for the 7 days (sun - sat) and it shows the total value. I have most in place (xcdatamodeld)... Is it possible to have CoreData fill text fields? Is there a good tutorial on completing core data? Most I have read and watched all use table views for the example.What I want to do is have the same data show up after closing and re-opening the App. // MARK: - Core Data stack lazy var persistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: Numbers) container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { // Replace this implementation with code to handle the error appropriately. // fatalError() causes the application to generate a crash log and termina
1
0
839
Apr ’21
Core Data errors when saving context after syncing from CloudKit
In my new SwiftUI app I am using NSPersistentCloudKitContainer API to persist my data and also share it between multiple different devices. I am always using viewContext to fetch or save records, also my Stack consists of two custom configurations where CloudKit is enabled. One for entities to be stored in the CK public database and one for records in the private database. This usually works just fine. I can save or delete records on one device and they appear on the other device. However in some situations, usually after I imported data on device A and use the same device to create a new record I get errors like this when saving context: Error Domain=NSCocoaErrorDomain Code=133020 Could not merge changes. UserInfo={conflictList=( NSMergeConflict (0x28126df40) for NSManagedObject (0x28242eda0) with objectID '0xb76a5d0f17dd5aa9 ' with oldVersion = 33 and newVersion = 34 and old object snapshot = {n id = D1E2B253-723C-406C-8566-2307DA2D5C17;n name = bench;n} and new cached row = {n id = D1E2B253-723C-4
3
0
1.9k
Mar ’21
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
Mar ’21
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
Feb ’21
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
Feb ’21
NSPersistentCloudKitContainer: How to know initial sync between CloudKit has happened?
I am looking into using the new NSPersistentCloudKitContainer to sync some internal data for my app. Generally it works great, but I have one scenario that I cannot figure out.Here the basic scenario, there is a single record in CloudKit that created and used to keep track of some internal state. Keeping it the cloud allows for two cases: when the user open the app on another device (say an iPad) and when the user re-installs the app on the same device.If its indeed the very first time the user is using the app on any device, I need to create the record with a bunch of default initial values. I am okay with spending a little time at app startup determining if its a brand new user or an existing user installing on another device.I thought maybe observing NSPersistentStoreRemoteChangeNotification would provide a useful point in time that I can say ah ha, now I know its a new user, or an existing user. However its gets called a lot and I cannot find anything in its userInfo that gives me a definitive an
4
0
3.8k
Dec ’20
Stale data in Core Data using NSPersistentCloudKitContainer
I have an app that's built entirely using SwiftUI. It uses NSPersistentCloudKitContainer to ensure that the iOS, watchOS and widgetKit targets all have the same fresh data. The problem is, this works well when the target is in the foreground, but once any of them are in the background, those targets serve stale data. As soon as they're brought into the foreground, the data gets merged in and I see the correct data. I can tell that this is the case because I have a background task running and when I read from my entity in the background, it is always stale. Because of this, my widget always shows stale data as well as my watch complications. Here are my findings. iPhone App: Data is only fresh when active, if I try reading from the bg, data is stale Watch App: Same as above WidgetKit: The data is only fresh on launch I don't think this is a bug, I think I'm just missing something in my implementation of Core Data. I know that there's Persistent History Tracking that might be a solution, but that seems
2
0
1.2k
Dec ’20
Reply to WidgetKit and CoreData/CloudKit
Short Answer: You can't achieve Core Data / iCloud sync with NSPersistentCloudKitContainer in Widgets I ran many tests with and without WidgetKit and I discovered that no matter what I tried, I could never get NSPersistentCloudKitContainer to sync while an app is in the background. There is no amount of time that you can wait either, the sync will simply not happen. I tried querying Core Data during BackgroundTasks and the data is simply never there. I can see that a sync operation gets queued with a priority of 2 but only when an app becomes active does the sync even run. Widgets always run in the background. Since NSPersistentCloudKitContainer only runs while an app is in the foreground and since widgets only run in the background, the sync will never happen unless you launch the app. This isn't ideal because say you have the app installed on another device like a watch, your widget on your phone will never receive the updates that you do on the watch. At least, not with NSPersistentCloudKitContainer
Nov ’20
Reply to Shared NSPersistentCloudKitContainer
It seems like anywhere I read, it says the same thing: It Does Not. Before iOS14 NSPersistentCloudKitContainer only worked with Private Database iOS14 + NSPersistentCloudKitContainer works with Public & Private Databases Soo NSPersistentCloudKitContainer does not work with the Shared Database even if you use CKShare to share the underlying CKRecord object. The user can access the shared object and modify it but through CloudKit Apis and not via NSPersistentCloudKitContainer sync mechanism to CoreData. Also, I have red multiple responses by Apple Engineers, and no where they hinted that they are working on it, or that if it is something technically viable for the future. So at this point, I don't know what to do, since obviously using CKShareApi outside CoreData will require a huge amount of App rewrite. References: https://developer.apple.com/forums/search/?q=NSPersistentCloudKitContainer
Nov ’20
Shared NSPersistentCloudKitContainer
Given the current quarantine and self isolation around the world, I was wondering if NSPersistentCloudKitContainer can be shared between users for collaborative work - pretty much like Pages or Keynote. I am aware of the new .public database scope, but this would rather be private with specific access by invitation. Is anyone aware of how to implement that?
1
0
660
Nov ’20
Reply to Is it safe to use a NSPersistentCloudKitContainer on a Share Extension?
Having used this API for two of my apps, and speaking with an Apple engineer, it sounds like we can assume the following: NSPersistentCloudKitContainer can be safely used in a Share Extension for storing data locally. It will complete the save operation locally. Uploading to CloudKit requires a scheduled background operation on the part of the API. Because of this, by the time the Extension is terminated, the background operation is not completed, and thus the CloudKit sync does not occur. In my testing, this leads to predictable behavior: Data is never uploaded from an Extension, however, Data is saved locally in your persistent container. And upon launching your app, with the container alive once more, it will sync your data to CloudKit. It's a bit unwieldy having to launch your app after an operation in an Extension, but from my own usage, I think it's safe to say that you can safely use NSPersistentCloudKitContainer, even if it doesn't sync as you or I would like. I truly hope this behav
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Apr ’21
Saving and fetching to Core Data
I am trying to save to Core Data so when the App is reopened the data will be there. I have a single ViewController, within that VC I have 10 Text Fields which the user inputs their data (numbers). I have a function where I add all the data for the 7 days (sun - sat) and it shows the total value. I have most in place (xcdatamodeld)... Is it possible to have CoreData fill text fields? Is there a good tutorial on completing core data? Most I have read and watched all use table views for the example.What I want to do is have the same data show up after closing and re-opening the App. // MARK: - Core Data stack lazy var persistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: Numbers) container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { // Replace this implementation with code to handle the error appropriately. // fatalError() causes the application to generate a crash log and termina
Replies
1
Boosts
0
Views
839
Activity
Apr ’21
Reply to CloudKit + CoreData: Now how do I take advantage of CloudKit user-to-user sharing without losing CoreData + CloudKit synchronization?
This would be amazing if it could work with NSPersistentCloudKitContainer directly
Replies
Boosts
Views
Activity
Apr ’21
[Core Data + CloudKit] How to exclude one model from being synced with the cloud?
I'm using NSPersistentCloudKitContainer to sync my Core Data stack with iCloud. I have one model that I want to be local to the device - how would I exclude that model from being synced while making sure it is saved to the device?
Replies
1
Boosts
0
Views
1.5k
Activity
Mar ’21
NSPersistentCloudKitContainer for Shares
Does anyone know if the new NSPersistentCloudKitContainer will work in an Application that shares data with others (CKShare), or will it only work as shown in the demo with other devices of the same iCloud Account?
Replies
15
Boosts
0
Views
5.6k
Activity
Mar ’21
Core Data errors when saving context after syncing from CloudKit
In my new SwiftUI app I am using NSPersistentCloudKitContainer API to persist my data and also share it between multiple different devices. I am always using viewContext to fetch or save records, also my Stack consists of two custom configurations where CloudKit is enabled. One for entities to be stored in the CK public database and one for records in the private database. This usually works just fine. I can save or delete records on one device and they appear on the other device. However in some situations, usually after I imported data on device A and use the same device to create a new record I get errors like this when saving context: Error Domain=NSCocoaErrorDomain Code=133020 Could not merge changes. UserInfo={conflictList=( NSMergeConflict (0x28126df40) for NSManagedObject (0x28242eda0) with objectID '0xb76a5d0f17dd5aa9 ' with oldVersion = 33 and newVersion = 34 and old object snapshot = {n id = D1E2B253-723C-406C-8566-2307DA2D5C17;n name = bench;n} and new cached row = {n id = D1E2B253-723C-4
Replies
3
Boosts
0
Views
1.9k
Activity
Mar ’21
Reply to Using NSPersistentCloudKitContainer causes crash for iOS 14
I called NSPersistentCloudKitContainer multiple times in a controller, and the same problem occurred. After modifying the code, the instance was created only once, and then called multiple times, the problem was solved.
Replies
Boosts
Views
Activity
Mar ’21
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!
Replies
11
Boosts
0
Views
3.2k
Activity
Mar ’21
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
Replies
6
Boosts
0
Views
1.8k
Activity
Feb ’21
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
Replies
2
Boosts
0
Views
1.3k
Activity
Feb ’21
NSPersistentCloudKitContainer: How to know initial sync between CloudKit has happened?
I am looking into using the new NSPersistentCloudKitContainer to sync some internal data for my app. Generally it works great, but I have one scenario that I cannot figure out.Here the basic scenario, there is a single record in CloudKit that created and used to keep track of some internal state. Keeping it the cloud allows for two cases: when the user open the app on another device (say an iPad) and when the user re-installs the app on the same device.If its indeed the very first time the user is using the app on any device, I need to create the record with a bunch of default initial values. I am okay with spending a little time at app startup determining if its a brand new user or an existing user installing on another device.I thought maybe observing NSPersistentStoreRemoteChangeNotification would provide a useful point in time that I can say ah ha, now I know its a new user, or an existing user. However its gets called a lot and I cannot find anything in its userInfo that gives me a definitive an
Replies
4
Boosts
0
Views
3.8k
Activity
Dec ’20
Stale data in Core Data using NSPersistentCloudKitContainer
I have an app that's built entirely using SwiftUI. It uses NSPersistentCloudKitContainer to ensure that the iOS, watchOS and widgetKit targets all have the same fresh data. The problem is, this works well when the target is in the foreground, but once any of them are in the background, those targets serve stale data. As soon as they're brought into the foreground, the data gets merged in and I see the correct data. I can tell that this is the case because I have a background task running and when I read from my entity in the background, it is always stale. Because of this, my widget always shows stale data as well as my watch complications. Here are my findings. iPhone App: Data is only fresh when active, if I try reading from the bg, data is stale Watch App: Same as above WidgetKit: The data is only fresh on launch I don't think this is a bug, I think I'm just missing something in my implementation of Core Data. I know that there's Persistent History Tracking that might be a solution, but that seems
Replies
2
Boosts
0
Views
1.2k
Activity
Dec ’20
Reply to WidgetKit and CoreData/CloudKit
Short Answer: You can't achieve Core Data / iCloud sync with NSPersistentCloudKitContainer in Widgets I ran many tests with and without WidgetKit and I discovered that no matter what I tried, I could never get NSPersistentCloudKitContainer to sync while an app is in the background. There is no amount of time that you can wait either, the sync will simply not happen. I tried querying Core Data during BackgroundTasks and the data is simply never there. I can see that a sync operation gets queued with a priority of 2 but only when an app becomes active does the sync even run. Widgets always run in the background. Since NSPersistentCloudKitContainer only runs while an app is in the foreground and since widgets only run in the background, the sync will never happen unless you launch the app. This isn't ideal because say you have the app installed on another device like a watch, your widget on your phone will never receive the updates that you do on the watch. At least, not with NSPersistentCloudKitContainer
Replies
Boosts
Views
Activity
Nov ’20
Reply to Shared NSPersistentCloudKitContainer
It seems like anywhere I read, it says the same thing: It Does Not. Before iOS14 NSPersistentCloudKitContainer only worked with Private Database iOS14 + NSPersistentCloudKitContainer works with Public & Private Databases Soo NSPersistentCloudKitContainer does not work with the Shared Database even if you use CKShare to share the underlying CKRecord object. The user can access the shared object and modify it but through CloudKit Apis and not via NSPersistentCloudKitContainer sync mechanism to CoreData. Also, I have red multiple responses by Apple Engineers, and no where they hinted that they are working on it, or that if it is something technically viable for the future. So at this point, I don't know what to do, since obviously using CKShareApi outside CoreData will require a huge amount of App rewrite. References: https://developer.apple.com/forums/search/?q=NSPersistentCloudKitContainer
Replies
Boosts
Views
Activity
Nov ’20
Shared NSPersistentCloudKitContainer
Given the current quarantine and self isolation around the world, I was wondering if NSPersistentCloudKitContainer can be shared between users for collaborative work - pretty much like Pages or Keynote. I am aware of the new .public database scope, but this would rather be private with specific access by invitation. Is anyone aware of how to implement that?
Replies
1
Boosts
0
Views
660
Activity
Nov ’20