Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

Reply to Logger messages not showing in XCode console
@eskimo I am using Logger (OSLog) and I don't want debug messages from frameworks like mentioned below. What should I do to achieve that? When I use CoreData / CloudKit especially NSPersistentCloudKitContainer I do see a lot of debug messages such as the ones below: CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](36): Validating options: containerIdentifier: databaseScope:Private ckAssetThresholdBytes: operationMemoryThresholdBytes: useEncryptedStorage:NO useDeviceToDeviceEncryption:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName: containerProvider: storeMonitorProvider: metricsClient: metadataPurger: scheduler: notificationListener: containerOptions: defaultOperationConfiguration: progressProvider: test_useLegacySavePolicy:YES archivingUtilities: bypassSchedulerActivityForInitialImport:NO stor
Topic: App & System Services SubTopic: Core OS Tags:
Nov ’22
FB11794798: NSPersistentCloudKitContainer throws lots of error / debug messages
Hi, When using NSPersistentCloudKitContainer lots of error / debug messages are shown in Xcode Debug area. Feedback FB11794798: Overview When I use NSPersistentCloudKitContainer I get the following error / debug messages printed on the Xcode Debug Area. Syncing seems to happen fine. Tested on device and simulator. I am still using Development (not deployed to Production yet) I even tried with a new project using the default code generated for by enabling CloudKit coredata sync and I still get the same messages. I have filed a feedback FB11794798 Steps to Reproduce Create a new project check Use CoreData and Host in CloudKit check boxes Run the project Notice the error messages shown below. Questions How to resolve these errors? Or is this a bug from the Apple Frameworks? (Feedback FB11794798) Error / debug message printed on Xcode debug area CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](36): Validating options: containerIdentifier:
0
0
1.4k
Nov ’22
NSPersistentCloudKitContainer - Import failed with error: Error Domain=NSCocoaErrorDomain Code=4864
The NSPersistentCloudKitContainer synchronization between core data and iCloud was working fine with phone 15.1. Connected a new iPhone iOS 15.5, it gives error: CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate managedObjectContextSaved:](2504): : Observed context save: - 2022-12-05 13:32:28.377000-0600 r2nr[340:6373] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _importFinishedWithResult:importer:](1245): : Import failed with error: Error Domain=NSCocoaErrorDomain Code=4864 *** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x53, 0x6f, 0x6d, 0x65, 0x20, 0x65, 0x78, 0x61) UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x53, 0x6f, 0x6d, 0x65, 0x20, 0x65, 0x78, 0x61)} CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _importFinishedWithResult:importer:](1245): : Import failed with error: Error Domain=NSCocoaErro
2
0
1.1k
Dec ’22
Reply to NSFetchedResultsController use-after-free issues in iOS 16.1
Yup! I am suddenly seeing a lot of crash reports (over 100 in the last couple of days) and ALL from users on iOS 16.1. This is new and nothing in that part of the App changed. Crashing right after the CoreData is initialized and NSPersistentCloudKitContainer is ready. At that point the controller does a fetchRequest for items in the Table and Crash with some kind of memory error. In my case it is simply making a request for items sorted alphabetically?!
Topic: App & System Services SubTopic: Core OS Tags:
Dec ’22
Unable to load CloudKit CoreData Store
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,
4
0
2.0k
Dec ’22
CoreData: Operation could not be completed 'Foundation_GenericObjError error 0'
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
1
0
1.7k
Jan ’23
Reply to In-app storage/sync strategy for shared objects
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:
Jan ’23
CloudKit Why is my Public Database empty?
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
2
0
1.4k
Jan ’23
CoreData & CloudKit toggle iCloud sync (enable/disable)
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
0
0
1k
Feb ’23
Core Data + CloudKit works for development but not production
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
2
0
912
Mar ’23
Reply to CloudKit container error
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
Apr ’23
NSPersistentCloudKitContainer stop sync when CKErrorDomain 12 error occurred
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
0
0
1.2k
Apr ’23
Reply to Core Data Plus CloudKit - Potential Issue / Question about Binary Data w/ External Storage
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
Apr ’23
Reply to preload core data from cloud kit
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
Apr ’23