Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

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
CoreData+CloudKit custom Zone
Hi, I'm using CoreData+CloudKit in a blank universal project for macOS 11 and iOS14. The records are in a private database inside a custom zone, I was able to set the correct database, but I'm yet to be able to set the zone. On the PersistentController created by default by Xcode 12 I have the following code let container: NSPersistentCloudKitContainer init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer(name: finances_manager_pro) let customZone = CKRecordZone(zoneName: CloudCore) guard let description = container.persistentStoreDescriptions.first else { fatalError(Error) } description.cloudKitContainerOptions?.databaseScope = .private if inMemory { container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: /dev/null) } container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError(Unresolved error (error), (error.userInfo)) } }) } And inside a View @FetchRequest( sortDescriptors: [NSSortDescrip
2
0
1.9k
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
655
Nov ’20
Reply to Invalid Bundle ID for container
I found a solution for my case, so I'm posting to help anyone else with a similar setup. If you're sharing a CloudKit container across multiple apps (using different bundle IDs), apart from specifying the container identifier when initializing the container, you must set NSPersistentCloudKitcontainerOptions on the NSPersistentCloudKit container (this is in the AppDelegate if you selected the Use CloudKit option during project creation) as shown below: let container = NSPersistentCloudKitContainer(name: ModelName) guard let description = container.persistentStoreDescriptions.first else { tt fatalError(No container descriptions available) } description.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier:iCloud.com.organization.ContainerName) container.persistentStoreDescriptions = [ description ] In your code, when you access the desired container, you use the same container ID as in the description above: let container = CKContainer(identifier: iCloud.com.organization.C
Nov ’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
Oct ’20
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
584
Oct ’20
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
957
Oct ’20
How to add CloudKit to iOS with Watch Project (xcode 12/swift ui)
There isn't a signing capability for icloud that is available for either the app or watchos extension targets. My end goal is to have the CoreData CloudKit container that is used by both applications to be in sync and fetch / update the models they modify. Here is what I've done so far: Create iOS with watch app cookie cutter app with xcode 12 Add Remote Notification for Background Modes for both the iOS and watch extension targets. Note I CANNOT find anything to do with icloud or cloudkit as a capability to add. Add the persistence context to the iOS App @main struct MyApp: App { tt@Environment(.scenePhase) private var scenePhase tt@StateObject private var persistentStore = PersistentStore.shared ttvar body: some Scene { ttttWindowGroup { ttttttContentView() tttttttt.environment(.managedObjectContext, persistentStore.context) tttt}.onChange(of: scenePhase) { phase in ttttttswitch phase { ttttttcase .active: ttttttttprint(active) ttttttcase .inactive: ttttttttprint(inactive) ttttttcase .background: ttttttttpr
1
0
1.5k
Oct ’20
Core Data: Using local and iCloud
Hi everyone, I'm trying to use in my app core data as persistent storage. In this app it is supposed to have some entities of core data local but also some other synced through iCloud. In the xcdatamodeld, I create two configs that belongs to each type offline(local) and the online(iCloud) but I'm getting a strange error where it says that it can't use the same container name. I don't understand if for each entity I want to be synced on iCloud I need a different container. Also, I do not understand because if I use only iCloud syncing without using any configuration, I can store different entities. Also, if each entity has a 1:1 relationship with the container, why is impossible to delete it, it doesn't make sense. Here is the code I'm using persistentContainer = NSPersistentCloudKitContainer(name: name, managedObjectModel: model) var defaultDirectoryURL: URL var descriptors = [NSPersistentStoreDescription]() for capability in self.dbCapabilities { if capability.cloudEnable { defaultDirectoryURL = NS
0
0
478
Oct ’20
Update an Existing Xcode Project Core Data with CloudKit & Manage Multiple Stores
Hi, I have.a project that uses CoreData and I want to add some of the data to iCloud to sync with a Watch app and I ticked the option for the Default configuration to use iCloud and It worked but now I don't want to include images in the cloud because it became too large so I Seperated the images into a different data thing and as per instructions here https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit/setting_up_core_data_with_cloudkit I added a configuration Local and Cloud and change the code as below - original lazy var persistentContainer: NSPersistentContainer = { ttlet container = NSPersistentContainer(name: DataModel) ttcontainer.loadPersistentStores(completionHandler: { ttttstoreDescription, error in ttttif let error = error { ttttttprint(Could load data store: (error)) tttt } tt}) ttprint(Loaded data store: DataModel) ttreturn container }() I created two configurations as per the video and ticked use with iCloud on the one I would like to sync with iCloud. n
1
0
1.5k
Sep ’20
iOS 14 WidgetKit + Core Data/CloudKit
I am trying to build a widget for iOS 14 using WidgetKit and CoreData/CloudKit instance on a new Xcode 12 project. I have added my CoreData's File Target Membership to both my app and widget I have added an App Group to my main App Target. My Persistence.swift looks like this: init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer(name: test-cd) let storeURL = URL.storeURL(for: group.test-data, databaseName: test-cd) let storeDescription = NSPersistentStoreDescription(url: storeURL) container.persistentStoreDescriptions = [storeDescription] 4. My widget looks like this: struct Provider: TimelineProvider { var managedObjectContext : NSManagedObjectContext init(context : NSManagedObjectContext) { self.managedObjectContext = context } ... } @main struct test_widget: Widget { let kind: String = test_widget var persistentContainer = PersistenceController.shared.container var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: Provider(context: persistentContainer.v
1
0
2.1k
Sep ’20
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
Sep ’20
Possible to override background push limits during development?
The video discusses limits to background pushes. I'm unable to finish developing my app that uses NSPersistentCloudKitContainer on iOS 14 because I believe background push notifications are being limited by the system so I am unable to test how the app behaves when it is suspended and a background push arrives. In fact I cannot get any background pushes to arrive at all, however pushes do arrive when the app is running in the foreground. Is there perhaps a development entitlement or launch param to override all limits so I can finish my app? And if not, can this feature be added please?
0
0
1.1k
Sep ’20