Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

Initialising CloudKit schema on public database fails for in Core Data with multiple strings (rdar://FB8995024)
Hi all, I'm trying to use NSPersistentCloudKitContainer.initializeCloudKitSchema() to initialise a public CloudKit database, but it seems to fail when any given entity has more than two String fields (or, it seems, any two fields which NSPersistentCloudKitContainer decides need to be CKAsset-backed). I've raised rdar://FB8995024 about this too, but was wondering if someone here can see something I'm missing. I can consistently reproduce this on iOS 14.4 (18D46) on the iOS Simulator with Xcode 12.4 (12D4e), or with an iPhone 11 Pro running iOS 14.4 (18D52) using this code (in a new iOS App project, SwiftUI/SwiftUI App/Swift, Use Core Data+Host in CloudKit) and a single Core Data entity with two String attributes: import CoreData import SwiftUI @main struct NSPersistentCloudKitContainer_initTestingApp: App { let persistenceController = PersistenceController.shared var body: some Scene { WindowGroup { Text(Success) } } } struct PersistenceController { static let shared = PersistenceController() let cont
4
0
3.0k
Feb ’21
Reply to Can I use NSPersistentCloudKitContainer while at the same time adding extra fields to my CloudKit CKRecord?
hi, my guess is that you're playing with fire if you go behind NSPersistentCloudKitContainer's back (!) if you want to keep the notion of an ordered set for a relationship among two entities that is A <---->> B (many B entities associated with an A, but only one A entity is associated with a given B), then two options come to mind (and these can be handled directly on the Core Data side). first, add an integer attribute to B to indicate its relative position among all its sibling B objects. if A changes the order of the B objects, just rewrite the position of each (or as may as needed) associated B. second ... perhaps if each B object represents lots of data and you think it an expensive operation to rewrite many B objects when reordered ... then consider adding an intermediate entity C with one integer attribute (perhaps named position) and two relationships: one from C to A (many-to-one) and one from C to B (one-to-one), so that you have A <---->> C <----> B. in essence, eac
Sep ’22
How to debug Core Data iCloud sync issue in production?
My app uses NSPersistentCloudKitContainer to sync Core Data objects among users' devices, and has been doing so successfully for about a year now. My issue is I can't find any way to debug when I have a specific user that is experiencing sync issues. I have had the user try every trick that I know of to resolve it but have had no luck. I have tried everything in the CloudKit dashboard, but no logs appear whatsoever. Anyone have any tips here?
1
0
1.1k
Jan ’21
Add NSManagedObject to existing CKShare
Using NSPersistentCloudKitContainer, how do I add (or modify) the NSManageObjects that are part of a Share/Zone? I have initially created a CKShare using NSPersistentCloudKitContainer.share(_:to:completion:), how can I add objects to that share later on? Calling the method again (with to:existingShare filed), always seems to create a new Share. In fact, I don't understand what the to: parameter is for? It doesn't matter if I set it or not, a new CKShare is always created.
3
0
1k
Jul ’21
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
How to sync data between iOS and OSX apps with CloudKit?
We have an iOS App developed in SwiftUI that saves data to CloudKit using NSPersistentCloudKitContainer. If I modify any of this data, the changes are synchronized on other iOS devices without problem. We also have an OSX App with StoryBoard using NSPersistentCloudKitContainer to share the same data with iOS devices. Changes made on OSX are updated immediately on iOS devices. But if any data is modified in iOS, it is not updated in the OSX application. Simply by doing Command-Tab twice the OSX app displays the new data. It appears that CloudKit Push Notifications are not causing the OSX application to detect that there are changes to the data and that it needs to be updated. In both cases an NSFetchedResultsController is created and a delegate is placed. The iOS one is called but the OSX one is not. The only difference in the code is that in the iOS app with SwiftUI it is done: var body: some Scene { WindowGroup { InitialTab() .environment(.managedObjectContext, DataManager.shared.viewContex
0
0
425
Jan ’24
CoreData Data Sharing with AppGroup
I have the following lines of code to access data through CoreData. import Foundation import CoreData import CloudKit class CoreDataManager { static let instance = CoreDataManager() let container: NSPersistentCloudKitContainer let context: NSManagedObjectContext init() { container = NSPersistentCloudKitContainer(name: ABC) container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { print(error.userInfo) } }) context = container.viewContext context.automaticallyMergesChangesFromParent = true context.mergePolicy = NSMergePolicy(merge: .mergeByPropertyObjectTrumpMergePolicyType) } func save() { do { try container.viewContext.save() print(Saved successfully) } catch { print(Error in saving data: (error.localizedDescription)) } } } I have confirmed that I can share data between iPhone and iPad. Now, I need to use AppGroup as well. I have changed my code as follows. import Foundation import CoreData import CloudKit class CoreDataManager { sta
1
0
116
May ’25
Data Collection
Hi everyone, I am very new to SwiftUi and am not sure about data collection to disclose. Does using the sign in with Apple feature and Core Data with CloudKit count as Data Collection? (if it does what would it come under) I use @AppStorage for the sign in and not the UserDeafult feature. For CloudKit I only use the inbuilt NSPersistentCloudKitContainer container and for saving the generic: viewContext.automaticallyMergesChangesFromParent = true viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy Thank you
0
0
358
Nov ’21
CD4CK Sample App Availability?
In the 2019 WWDC sessiom 202 Using Core Data With CloudKit it was mentioned...“we're also introducing a new sample application this year that's designed to give you something to hold in your hands, to feel how NSPersistentCloudKitContainer works along with all these other features of Core Data.”Does anyone know if that's available yet, and if so, where to find it? Or even when it might be available? Thanks.
1
0
547
Aug ’19
CoreData data disappears locally after disabling iCloud in device Settings
I've built an app and got it working nicely with CoreData, and now I want to integrate it with CloudKit. I have made some minor changes to my code (namely updating NSPersistentContainer to NSPersistentCloudKitContainer and CloudKit works - I can see records appearing in the iCloud dashboard and I can modify records from the iCloud dashboard and the changes reflect on my device. Great. However, if I disable iCloud syncing via Settings on my device (without force-quitting my app) I notice a couple of things: When switching back to my app if I try and edit an entity I sometimes get an app crash If I quit and reload the app all my data has disappeared from my device (it still remains in iCloud). Is this expected behaviour? Ideally, what I would like, is that the data persists locally if a user has added records but then later decides to disable iCloud syncing on the app. Here's my code in case I've done anything funky with the implantation. It feels pretty simple, but maybe that's the problem. CoreDataMa
1
0
752
Jul ’23
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
560
Apr ’21
CloudKit not working properly in iOS 17 RC
CloudKit was working perfectly in iOS 16. However after updating to iOS 17 RC on my devices iCloud sync no longer works properly. The app has a package called CloudKitSyncMonitor which shows the sync status. Normally it would say Synced with iCloud but on iOS 17 it is either stuck in the Syncing or Sync not started state and the data doesn’t update. This mostly happens after a reinstall of the app. After some time it randomly decides to work until I uninstall the app. I’m really confused what could be the problem if it was working fine on iOS 16 but barely works properly on iOS 17? This is currently the code I have for the DataController: import SwiftUI import CoreData class DataController { var container: NSPersistentCloudKitContainer @AppStorage(wrappedValue:true,syncEnabled,store:UserDefaults(suiteName: group.com.ip18.SubManager)) var syncEnabled static let shared = DataController() init() { container = NSPersistentCloudKitContainer(name: Subscriptions) load(syncEnabled: syncEnabled) } fu
4
0
2k
Sep ’23
CloudKit Private Database Record Zone Limit
I am following this document from Apple to implement sharing with CloudKit. In it, Apple says NSPersistentCloudKitContainer uses CloudKit zone sharing to share objects. Each share has its own record zone on the CloudKit server. CloudKit has a limit on how many record zones a database can have. What is the record zone limit for a private CloudKit database? I can find information about record and participant limits but not on record zone limits.
1
0
362
May ’24
CoreData + CloudKit: Cocoa-Error 134419
Hi, Some of my users are experiencing synchronization issues when using the NSPersistentCloudKitContainer in CoreData. My app is listening to any errors that occur during the synchronization with the NSPersistentCloudKitContainer.eventChangedNotification Notification. Before I just got Cocoa-Errors 2 or 3 which indicate a bad network connection or something similar. Now I received reports with a Cocoa-Error 134419. Does anyone know what this error code means? Maybe someone from the Core Data team could have a look at this. Thanks a lot, Alexander
1
0
1.9k
Nov ’21
Share RecordZones or ParentRecords in CoreData-CloudKit Share
Hello everyone, in the App I'm building I'd like to share an entire list of items (records) by just sharing the list itself (parent record or RecordZone). Meanwhile, I'd like to continue using the NSPersistentCloudKitContainer and therefore CoreData sync. Is it possible, with the new features Apple introduced (Sharing RecordZone and Sharing in Cloud & Local Storage), to do what I described, and combine both functions. Thank you, Carlos Steiner
0
0
763
Dec ’21