I'm using NSPersistentCloudKitContainer and I'm getting warnings in the console saying: CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _scheduleAutomatedExportWithLabel:activity:completionHandler:]_block_invoke(3457): - Finished automatic export - AppActivationExport - with result: storeIdentifier: F2C60E7A-CEC4-44F2-B467-7324C065AD33 success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134406 Request '1FA53D40-43FB-4751-8719-0D26393D5301' was aborted because the mirroring delegate never successfully initialized due to error: UserInfo={NSLocalizedFailureReason=Request '1FA53D40-43FB-4751-8719-0D26393D5301' was aborted because the mirroring delegate never successfully initialized due to error: } I have added indexes for recordName and modifiedTimestamp to all my records as queryable as per the instructions.
Search results for
NSPersistentCloudKitContainer
589 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi, My macOS app's production build is crashing on start with an unhelpful crashdump. In the console, the only error in the Console is BUG IN CLIENT OF CLOUDKIT: Not entitled to listen to push notifications. Please add the 'com.apple.private.aps-connection-initiate' entitlement. Adding this entitlement to my entitlements.plist breaks the app entirely (Unsatisfied entitlements). Here is how I'm loading my persisten store: lazy var persistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: ChatModel) guard let description = container.persistentStoreDescriptions.first else { fatalError(###(#function): Failed to retrieve a persistent store description.) } if(UserDefaults.standard.bool(forKey: StoredPreferenceKey.iCloudSync)){ description.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: iCloud.XXXXX) } else { description.cloudKitContainerOptions = nil } description.setOption(true as NSNumber, forKey: NSPersistentH
I'm using NSPersistentCloudKitContainer together with a private and public database. I have a public database with articles. Users should be able to like an article but I'm wondering what would be the best design approach to achieve this. The users can also add articles that they find online which are then automatically liked for the user adding it (and uploaded to the public database) Question 1 I want you to be able to see how many people have liked an article, so I think there will perhaps be an array on the article with the userId who liked it and then you just do a count on it? Or do you think there is a better way? Question 2 I am thinking about how the liked article should be saved for the user, either put that article in their private database, but then that article will be disconnected from the public article. Or I can filter out among the public articles that contain the user's userId (however, I'm a little unsure how it works in practice as the public database is polled every 30 minutes wi
Hi, I've previously used a local core data database successfully with my app and now I wanted to use NSPersistentCloudKitContainer to store the data in CloudKit. However when I do container.initializeCloudKitSchema(options: []) I receive an error which I'm not able to comprehend: CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _requestAbortedNotInitialized:](2112): - Never successfully initialized and cannot execute request ' 17E8940B-00D6-4D01-AA78-6A04EBEBC957' due to error: ... 9 Batch Request Failed CKError's omited ... }> I also get this error in the console: Atomic failure = I've tried to reset Reset Environment in the CloudKit dashboard to no avail.
This what I use in my apps (during the initialisation of my Data Controller): self.mainContainer = { let container = NSPersistentCloudKitContainer(name: MyDataModel) container.loadPersistentStores(completionHandler: { description, error in if let error = error { print(**** ERROR loading persistent store (error)) } //Setup auto merge of Cloudkit data container.viewContext.automaticallyMergesChangesFromParent = true container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy //Set the Query generation to .current. for dynamically updating views from Cloudkit try? container.viewContext.setQueryGenerationFrom(.current) }) return container }() The key lines are the 2 below //Setup auto merge. Also, be sure to have enabled Remote Notifications in Background modes of the App's Signing and Capabilities. I hope this helps. Regards, Michaela
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
I am using the NSPersistentCloudKitContainer for my app's core data. This works well enough on a single device. However, (using the same Apple ID) when I run my app on a second device, the data on cloud kit is ignored. What is the magic code needed to pull the cloud kit data into my app's core data store?
hi, as long as you're OK with I will never manipulate the CloudKit data directly, then i don't see what the problem is. i doubt that the NSPersistentCloudKitContainer designers ever intended for users to be interacting directly in code with CKRecords and making an end run around what NSPersistentCloudKitContainer does for you automatically. however, that aside, i do recall reading at one point that Core Data does not necessarily use external storage just because you checked Allows External Storage. it could be the case that Core Data made such decisions about your data at some point; if so, the CloudKit representation of what NSPersistentCloudKitContainer does for you would probably respect that decision. hope that helps, DMG
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
My app uses NSPersistentCloudKitContainer to implement Coredata and iCloud synchronization data Recently, I received feedback from online users about data synchronization errors, and the error code is CKErrorDomain 12 . In the App, I use NSPersistentCloudKitContainer.eventChangedNotification to monitor the synchronization status, the following is the specific code NotificationCenter.default.publisher(for: NSPersistentCloudKitContainer.eventChangedNotification) .sink(receiveValue: { notification in if let cloudEvent = notification.userInfo?[NSPersistentCloudKitContainer.eventNotificationUserInfoKey] as? NSPersistentCloudKitContainer.Event { let event = SyncEvent(from: cloudEvent) } }) .store(in: &disposables) When the user feedbacks that the data cannot be synchronized, it can be seen from the above code that an error occurred when CoreData + iCloud was exporting data. At the same time, cloudKitEvent.error does not contain any error information, only CKErrorDomain 12 this information, I don’t know
In case others get stuck with this, I created a new container and ensured the container = NSPersistentCloudKitContainer(name: name) , and the CoreData file was the same name and all went fine afer. I also made sure the container name, et.al. was a short name and was different from the BundleID. Blessings, --Mark
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
I enabled Core Data + CloudKit for my MacOS and iOS app to allow sync between the two. I was able to test the sync during development and it's been syncing to My development database container just fine and I can fetch the changes from both my apps. However, once I distributed my app to test flight/app store, the Production database is not getting any activity at all. I did made sure I deploy my database schema to production per other troubleshooting post online. Am I missing any additional setup required for production? Below is my Persistence struct for reference (edited the App Name, using the the name of my app in actual file): static let shared = PersistenceController() let container: NSPersistentCloudKitContainer init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer(name: App Name) // Only initialize the schema when building the app with the // Debug build configuration. #if DEBUG do { // Use the container to initialize the development schema. try container.initializ
I want to give the user the option to toggle iCloud sync on and off. So I'm switching between NSPersistentCloudKitContainer and NSPersistenttContainer But... When I switch off the CloudKit synchronization and update the container, the sync is still active. After restarting the app manually the sync is deactivated. This is the same problem some people are describing in the comments here... https://stackoverflow.com/questions/65355720/coredatacloudkit-on-off-icloud-sync-toggle I wasn't able to find a solution. Here is my code: MyApp.swift @main struct MyApp: App { @StateObject private var persistenceContainer = PersistenceController.shared var body: some Scene { WindowGroup { ContentView() .environmentObject(CoreBluetoothViewModel()) .environment(.managedObjectContext, persistenceContainer.container.viewContext) } } } PersistenceController import CoreData class PersistenceController: ObservableObject{ static let shared = PersistenceController() lazy var container: NSPersistentContainer = { setupContain
Hello. I am beta testing an app in TestFlight. I want to use a public database inside the cloudkit container, and I think that I have set things up that way (see below). But my testers can only see their own data and all records are being stored in the Private Database. I'm getting the results I want on my own iPhone (loading the app directly from xCode). But testers are not getting the same experience. It this because I am in TestFlight? Are there settings I have missed? Here is what I have done so far: In my DataController I have this: init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer(name: Main) if inMemory { // this is set in static var preview container.persistentStoreDescriptions.first?.url = URL(fileURLWithPath: /dev/null) } guard let description = container.persistentStoreDescriptions.first else { print(Can't set description) fatalError(Error) } let publicStoreURL = description.url!.deletingLastPathComponent().appendingPathComponent(public.sqlite) let containerIdentifie
How important is user privacy? How important is security? How are you planning to pay for cloud services like FireBase or AppWrite? I choose CloudKit (and CoreData), time and again, because, user data is private and secure by default, the capability to share between users is built in on top of that privacy and security, and users pay for their own cloud storage, not me. In 2019, Apple introduced a sync system between the CloudKit and CoreData, called NSPersistentCloudKitContainer, which might server you well. If you want more control, check out CloudCore. And for Android, check out cloudkit_flutter. fwiw
Topic:
Programming Languages
SubTopic:
Swift
Tags:
I'm encountering the error 'Operation could not be completed 'Foundation_GenericObjError error 0'' when loading my canvas on my SignupView. No errors are showing in my code, I've tried all sorts of fixes and nothing seems to work. Any help would be appreciated, if you need more code I will update post. SignupView @Environment(.managedObjectContext) private var viewContext @FetchRequest( sortDescriptors: [NSSortDescriptor(keyPath: Account.userSince, ascending: true)], animation: .default) private var savedAccounts: FetchedResults .onAppear(perform: userData) .fullScreenCover(isPresented:$showHomeView, content: { HomeView().environment(.managedObjectContext, viewContext) func userData() { Auth.auth().addStateDidChangeListener { auth, user in if let currentUser = user { if savedAccounts.count == 0 { // Add data to Core Data let userDataToSave = Account(context: viewContext) userDataToSave.name = currentUser.displayName userDataToSave.userID = currentUser.uid userDataToSave.numberOfCertificates = 0 userDataToSave
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Xcode
Xcode Sanitizers and Runtime Issues
SwiftUI
Core Data
I have a CoreData model, in a Swift Package with tests. I can successfully run the tests, when I load the model using NSPersistentContainer, however attempting this with NSPersistentCloudKitContainer always fails in the call to loadPersistentStores(completionHandler block: @escaping (NSPersistentStoreDescription, Error?) -> Void) The error is : [CK] BUG IN CLIENT OF CLOUDKIT: Not entitled to listen to push notifications. Please add the 'aps-connection-initiate' entitlement. This issue is described on StackOverflow however, the accepted solution does not appear to work in my case. I have tried adding the aps-connection-initiate key to my App Info.plist, the Test Info.plist and the SPM bundle. No change. (NB. adding this to the entitlements file just breaks auto signing). I have enabled App entitlements for App Groups, Remote Notifications background mode, Push Notifications and iCloud CloudKit with a store identifier. I have checked my model. All relationships have inverses. No unique constraints,