Search results for

NSPersistentCloudKitContainer

589 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
858
Jun ’21
Why? "CloudKit integration does not support unique constraints"
Hi, On iOS 14 beta 1-3 I was happily using a constraint on several entities in NSPersistentCloudKitContainer. The part of the app using this was essentially an RSS reader - two different devices were independently fetching news and no duplicates due to the constraints. Now on iOS14 beta 4 I'm receiving CloudKit integration does not support unique constraints, which means I've had to remove the constraints.. Now the app is subject to CloudKit sync vs RSS import timing issues.. if CloudKit syncs after the RSS import then there are duplicate items. What's the workaround for this please? It really should just work. Thanks, Andy
6
0
4.6k
May ’21
NSPersistentCloudKitContainer - how to reset CoreData+CloudKit after failed automatic migration (while still in development environment)
I have expanded my CoreData model quite a few times, including renaming entities, properties (and as far as I remember relationships). I am still working in the (CloudKit) development environment, only. Now I am getting errors each time I start the app (one line out of many shown): CoreData: debug: CoreData+CloudKit: -PFCloudKitMetadataModelMigrator calculateMigrationStepsWithConnection:error:(404): Skipping migration for 'ANSCKDATABASEMETADATA' because it already has a column named 'ZLASTFETCHDATE' The app is working as expected, it seems this error has no effect on correct CoreData+CloudKit execution. But I want to get rid of this error warning before I deploy to production for TestFlight or expand CoreData further. To have a clean CD+CK base I can start migrations from in future. Can I just reset CD (or CoreData's model) to make CD accept the current model as the base model without any migrations attached to it? An Apple Engineer suggested here - https://developer.apple.com/forums/thread/47637?answerId=146
3
0
2.9k
Apr ’21
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
830
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