Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

Switching from production to development database
Hello! I have a live app in the appstore which uses NSPersistentCloudKitContainer. When I was working on the app, whatever data was created while testing was reflecting in the Development section of the CloudKitDashboard. Then, when time came for releasing the app, I had pushed my schema to production and everything has been working well. Recently, I have been working to make some changes in my code and while testing I realised that that I am being pointed to Production. Now how do I move back to using Development while working on the app. I have tried changing values of in .entitlement file. But it still does not give me what I want. Below is my entitlement values: aps-environment development com.apple.developer.icloud-container-environment Development com.apple.developer.icloud-container-identifiers Does anyone have any suggestions?
0
0
489
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
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
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
972
Jun ’21
Accept CKShare with SwiftUI App lifecycle
In iOS 15, macOS 12, tvOS 15 and watchOS 8 we can finally share NSManagedObjects using NSPersistentCloudKitContainer 🎉 I've been playing around with it and I've managed to share an object from one Apple ID to another. But I'm unable to accept the invite. 😰 If I understand the docs correctly I'm supposed to call func acceptShareInvitations(…) with CKShare.Metadata representing the invite. This metadata should be forwarded to my app using either AppDelegate or SceneDelegate. The problem is that I'm using the SwiftUI App-protocol. I tried setting up an UIApplicationDelegateAdaptor with this code: ivar added @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate AppDelegate implemented class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata) { assertionFailure() } } The assertionFailure is never called, so my guess is that the SceneDelegate is being called instead. So, how do I im
0
0
876
Jun ’21
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
904
Jun ’21
Reply to Initialising CloudKit schema on public database fails for in Core Data with multiple strings (rdar://FB8995024)
@Nick: Initialising against the private database as you suggested works on iOS 14.5. It would be really useful if that was in the documentation for initializeCloudKitSchema() if it's not likely to be fixed to support initialising against a public database, to avoid others falling into the trap I did! I've commented to that effect on FB8995024, too. On iOS 15, I can't verify if that's also the case yet because of FB9156476 (the feedback I created during our lab session). For the sake of anyone else who finds this thread, the error that feedback refers to is below. FB9156476 (iOS 15 NSPersistentCloudKitContainer can't sync initial data from server with “Failed to sync user keys”) error: 2021-06-10 21:51:53.672655+0100 MyApp[1230:15921] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(955): : Failed to set up CloudKit integration for store: (URL: file:///Users/steve/Library/Developer/CoreSimulator/Devices/59435252-2CF1-4980-8ABB-4B46B21385AA/data/Conta
Jun ’21
NSPersistentCloudKitContainer and App Extensions
Can the behavior of NSPersistentCloudKitContainer be described in App Extensions? I have seen Forum entries that describe its behavior in Widgets - it will save data locally, but will not sync that data until the app is opened. This is a pretty major downsides for any apps that use SiriKit Extensions to allow for quick, simple data entry -- not syncing the data until the app is opened (which could be days later) would be a deal breaker. I hope this can be clearly described, and improved (if my understanding is correct) - I've filed a feedback to document this as well: FB9170155
0
0
945
Jun ’21
NSPersistentCloudKitContainer with public database doesn't work and is poorly documented
So I tried the public database feature of NSPersistentCloudKitContainer last year but never really got anywhere so I thought i'd try it again this year. However I've still had basically no luck and I figured now might be a good time to try and document the issues I have had. The documentation for this at https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit/creating_a_core_data_model_for_cloudkit mentions shouldInitializeSchema which from what I can gather was removed in a beta version a long ** time ago. It appears to now be a method on the container - container.initializeCloudKitSchema(). Ya'll should update this documentation. initializeCloudKitSchema does not work if you have options.databaseScope = .public on the NSPersistentCloudKitContainerOptions. You get a bunch of errors saying No authToken received for asset Turning off the public scope and then calling initializeCloudKitSchema gets you the Record types you need created in the CloudKit console, then r
9
0
6.2k
Jun ’21
How is Record Zone Sharing done?
My use case is the following: Every user of my app can create as an owner a set of items. These items are private until the owner invites other users to share all of them as participant. The participants can modify the shared items and/or add other items. So, sharing is not done related to individual items, but to all items of an owner. I want to use CoreData & CloudKit to have local copies of private and shared items. To my understanding, CoreData & CloudKit puts all mirrored items in a special zone „com.apple.coredata.cloudkit.zone“. So, this zone should be shared, i.e. all items in it. In the video it is said that NSPersistentCloudKitContainer uses Record Zone Sharing optionally in contrast to hierarchically record sharing using a root record. But how is this done? Maybe I can declare zone „com.apple.coredata.cloudkit.zone“ as a shared zone?
2
0
1k
Jun ’21
Question about NSPersistentCloudKitContainer and sharing
Hopefully everyone's recovered from WWDC2021 last week! I've been digging through as much of the new documentation as I can about the NSPersistentCloudKitContainer and sharing over the last couple of days (since I can't get my code working in the XC 13 Beta... looks like a couple of bugs, I think...), and have a question. It appears that this uses Sharing by Record Zone rather than Sharing by Record, which is fine, but... How does this work when you are sharing entities between multiple users? for example... My Db contains a hierarchy of entities under a single root node, and there are multiple such entities (at the moment without overlap between the sub-entities, but I feel like that's just around the corner). Lets call them Entities A, B, and C. Now: Entity A I want to share with Joe. Entity B I want to share with Joe and Sally. Entity C I want to share with Sally and Simon. So, for Entity A I presume that it (and it's sub entities) wind up being represented in a shared record zone (SRZ) of it's ow
0
0
902
Jun ’21