Search results for

“NSPersistentCloudKitContainer”

601 results found

Post

Replies

Boosts

Views

Activity

Reply to Check Data Re-Sync on App Reinstall with CloudKit (+SwiftUI)
I'm using an almost identical CoreData stack as to what was shown in the WWDC 2019 Posts demo app. Here's the code: import Foundation import CoreData // MARK: - Core Data Stack /** The main Core Data stack setup including history processing./ class CoreDataStack { tt/** ttttA persistent container that can load cloud-backed and non-cloud stores. tt */ ttlazy var persistentContainer: NSPersistentCloudKitContainer = { tttt tttt// Create a container that can load CloudKit-based stores ttttlet container = NSPersistentCloudKitContainer(name: MyCoreDataApp) tttt tttt// Enable history tracking and remote notifications ttttguard let description = container.persistentStoreDescriptions.first else { ttttttfatalError(###(#function): Failed to retrieve a persistent store description.) tttt} ttttdescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) ttttdescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) tttt ttttcontainer.loadPer
Jun ’20
Reply to Restart sync when using NSPersistentCloudKitContainer
With the following code I'm successfully turning On or Off sync between CoreData and CloudKit. I have iCloudSync saved in UserDefault / @AppStorage and controlled with a toggle switch in my app settings. This line is what turn it off description.cloudKitContainerOptions = nil, I hope it helps. class CoreDataManager: ObservableObject{ // Singleton static let instance = CoreDataManager() private let queue = DispatchQueue(label: CoreDataManagerQueue) @AppStorage(UserDefaults.Keys.iCloudSyncKey) private var iCloudSync = false lazy var context: NSManagedObjectContext = { return container.viewContext }() lazy var container: NSPersistentContainer = { return setupContainer() }() func updateCloudKitContainer() { queue.sync { container = setupContainer() } } func setupContainer()->NSPersistentContainer{ let container = NSPersistentCloudKitContainer(name: YourCoreDataContainerName) guard let description = container.persistentStoreDescriptions.first else{ fatalError(###(#function): Failed to retrieve a persis
Jun ’24
Reply to How to read/write to App1’s database from App2?
OK, I've solved my issue. 1st of all, defining 2 NSPersistence : ObservableObjects most definitely wasn't the way to go: @StateObject var app1DB = PersistenceApp1.shared @StateObject var app2DB = PersistenceApp2.shared I just needed one: @StateObject var persistence = Persistence.shared deeje's answer pointed me in the right direction, but what was still missing for me were the following 3 key ideas: container's name: is just the name of the .xcdatamodeld - and that this has nothing to do with what I expected (ie, that it was somehow related to my CloudKit container ids “iCloud.com.company.App1”) container = NSPersistentCloudKitContainer(name: Model) Within Model.xcdatamodeld I needed to define 2 separate configurations - with each configuration holding the Entities that are held within the the CloudKit containers: App1Config - holds the Entity from iCloud.com.company.App1, and App2Config - holds the Entity from iCloud.com.company.App2 I needed 2 store descriptions for each app, and to specify the sq
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’22
How to save an audio file using Core Data + CloudKit?
I am transitioning to using CloudKit for syncing, using NSPersistentCloudKitContainer to manage syncing. In my app you can record audio, and I've been saving that by saving the file to disc and storing a relative URL to Core Data. How can I get this to work using NSPersistentCloudKitContainer? I read that I shouldn't store large data as a CoreData attribute for performance, but I need the data to sync with CloudKit.
1
0
1.3k
Feb ’21
Reply to WidgetKit and CoreData/CloudKit
In testing today, syncing in the background with NSPersistentCloudKitContainer seems to be working more reliably with the iOS 16 SDK. The first time you change something on another device it still seems to schedule a task to perform that work with utility priority (via -[NSCloudKitMirroringDelegate checkAndScheduleImportIfNecessary:andStartAfterDate:] which logs Scheduling automated import with activity CKSchedulerActivity priority 2 Utility), so it doesn't execute right away. If you change it again then I'm seeing it does immediately import the two accumulated changes (NSCloudKitMirroringDelegate Beginning automated import - ImportActivity - in response to activity, then -[PFCloudKitImportRecordsWorkItem applyAccumulatedChangesToStore:inManagedObjectContext:withStoreMonitor:madeChanges:error:] followed by NSCloudKitMirroringImportRequest Importing updated records) which triggers NSManagedObjectContextObjectsDidChange, NSPersistentStoreRemoteChange, and NSPersistentCloudKitContainer.eventChangedNotif
Jun ’22
Reply to CloudKit sync stopped working with error „You can't save and delete the same record"
Thanks for the reply! Firstly, correct, we're using CoreData + CloudKit and mirrored relationships means reflexive relationships (e.g., Article.similarArticles whereby both are of the type Article). Assuming that you are using Data + CloudKit, I am guessing that this can be triggered by your code and data. Regrettably, that doesn't seem to be the case, also given the Delete Rule is Nullify. Digging through our old messages, we found out that we had already reported this very same issue a couple of years ago with a similar data model but where no entity was ever deleted. At that time we filed feedback report 9118745 and we were told that this was likely a bug. it is worth filing a feedback report for the Core Data team Given this seems to be the very same issue, I’ve added the information of this post to our above ticket (and have provided the relevant system diagnose logs, data model, etc. there too). Does your Core Data model indeed has the reflexive relationship? If yes, has it been there for long time, or
Jan ’25
Reply to WidgetKit and CoreData/CloudKit
Hi cristosv, Thanks for posting your solution to this online. I'm having the same problem, but it would be great it for you could help a little more. For example, all your code is working fine, but I can't seem to figure out how to use my core data entity in a Text() view in my widget. Below is my code, and any help with this or more sample code would be great. Thanks 🙏 import WidgetKit import SwiftUI import Intents import CoreData struct Provider: IntentTimelineProvider { func placeholder(in context: Context) -> SimpleEntry { SimpleEntry(date: Date(), configuration: ConfigurationIntent()) } func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) { let entry = SimpleEntry(date: Date(), configuration: configuration) completion(entry) } func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline) -> ()) { var entries: [SimpleEntry] = [] // Generate a timeline consisting of five entries an
Aug ’20
CoreData with CloudKit in WidgetKit not working
In my app, I have an NSPersistentCloudKitContainer set up in the following way: let container: NSPersistentCloudKitContainer init() { self.container = NSPersistentCloudKitContainer(name: Model) self.container.persistentStoreDescriptions[0].setOption( true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey } self.container.loadPersistentStores { (_, error) in guard error == nil else { print(error loading store: (error.debugDescription)) return } } self.container.viewContext.automaticallyMergesChangesFromParent = true } When I invoke a fetch request on the context of the container in my iOS target, it works as expected. However, when I perform the same fetch request in my Widget target, it returns an empty array result. In my iOS target, I have Background Modes / Remote Notifications and iCloud / CloudKit capabilities. In my Widget target, I have the iCloud / CloudKit capability. Not sure why it isn't working, so any help would be much appreciated, thanks!
3
0
1.1k
Sep ’20
Reply to NSBatchInsertRequest
HiI try to use the NSBatchInsertRequest. but the insertResult is nil, and my CoreData is emptyI use the viewContext of the NSPersistentCloudKitContainer.let container = NSPersistentCloudKitContainer(name: CoreDataPerformance) container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError(Unresolved error (error), (error.userInfo)) } }) try container.viewContext.setQueryGenerationFrom(.current) let moc = container.viewContext moc.automaticallyMergesChangesFromParent = true moc.perform { let insertRequest = NSBatchInsertRequest(entity: Client.entity(), objects: clients) let insertResult = try? moc.execute(insertRequest) as? NSBatchInsertRequest if let success = insertResult as? Bool { print(RESULT: (success)) } }This is the error I receive in the console.2020-02-04 18:30:25.800705+0200 CoreDataPerformance[62836:778869] [error] warning: Multiple NSEntityDescriptions claim the NSManagedObject subclass 'CoreDataPerformance.Client' so +entity
Feb ’20
Receiving NSPersistentStoreRemoteChange notification when app is closed
I use NSPersistentCloudKitContainer to fetch/sync data across multiple devices with the same iCloud account. /// ... container = NSPersistentCloudKitContainer(name: containerName) let description = container.persistentStoreDescriptions.first description?.setOption( true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) description?.setOption( true as NSNumber, forKey: NSPersistentHistoryTrackingKey) let viewContext = container.viewContext viewContext.automaticallyMergesChangesFromParent = true viewContext.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump NotificationCenter.default.addObserver( forName: .NSPersistentStoreRemoteChange, object: container.persistentStoreCoordinator, queue: .main ) { _ in Task { @MainActor [weak self] in // fetch new data and update widgets with it // ... viewContext.fetch ... // WidgetCenter.shared.reloadAllTimelines() } } } /// ... Everything works fine when my app in the foreground. How can I achieve the same when my app is clos
0
0
734
Oct ’23
Reply to NSPersistentCloudkitContainer Memory Leak -> Crash? (iOS 15 beta 4 & 5)
Sorry, Apple... this is still broken in iOS 15.1 (beta 2) The CPU & RAM usage is still excessive and no syncing occurs at all. I've replied to my TSI in the hope I can get someone to look into this as a matter of urgency. I now have users running iOS 15 who are no longer seeing their data syncing via iCloud, resulting in a terrible user experience, using my app downloaded from the App Store which has been unchanged since iOS 14. Whatever Apple did in iOS 15 beta 4 to NSPersistentCloudKitContainer, they broke it badly. Maybe users who don't have complex databases aren't seeing this problem, but the whole point of NSPersistentCloudKitContainer is to sync a Core Data store with complex relationships (and besides, it works just fine on iOS 13 & iOS 14!). My testing setup Monterey (beta 8) Xcode 13 (13A233) non-beta Testing on iPhone 13 Pro with iOS 15.1 (beta 2) Preparation Deleted iCloud data for my app Deleted my app from the device (App Store download) Rebooted device Reset the iCloud
Sep ’21
Reply to MacOS CloudKit production environment is not working properly
I have recently been experiencing issues in the Production Environment as well, although I cannot confirm if it is the same situation. My app is Mac only. I am adding iCloud support to an existing app that is already on the Mac App Store. I am testing such support via TestFlight builds. I am not using SwiftData but traditional Core Data with NSPersistentCloudKitContainer. – When making use of the Production Environment, only partial synchronization took place. This has not been an issue when run in the Development Environment. This occurred multiple times even when testing using accounts with different App IDs. My only thought was that perhaps iCloud also needed to be enabled as a Capability in Certificates, Identifiers & Profiles. That did not end up being the case. However, I was surprised to see that two iCloud Containers were enabled for this app even though only one was selected for the target in Xcode. After removing the unused container from the list and saving, I performed the following a
Nov ’24
Reply to Core Data CloudKit stops syncing after incomprehensible archive error
This error message your post provided indicates that Core Data failed to unarchive the import request (NSCloudKitMirroringImportRequest). Archiving / unarchiving an import / export request is a Core Data internal logic, and so I agree your assessment that it is not about your code. The feedback report you filed (FB10392936) doesn't mention the error message, and so I'd suggest that you file a new one to specifically report the error – If you do so, please share your report ID here for folks to track. Regarding FB10392936, you most likely hit CloudKit throttles. For more information of this topic, see the following documentations: TN3162: Understanding CloudKit throttles Understand system throttles. When uploading a big data set and hitting CloudKit throttles, the only thing you can do is to lower the CloudKit operation rate. When using Core Data + CloudKit, however, you don't control how NSPersistentCloudKitContainer synchronizes data. Based on today's API, the only thing you can do is to somehow con
Oct ’24
Reply to Access Core App Data from IOS widget
I wanted to give this thread a bump because I too am facing the same issue. The proposed answer from rr0924, and the referenced article from Antoine van der Lee, does not work for me either. To inject my CoreData model into the Widget extension one failing attempt I've tried was to use a similar method in my iOS app and watchOS companion app. For example this code will allow proper access to CoreData from iOS and watchOS; @main struct RunRosterApp: App { @Environment(.scenePhase) private var scenePhase @StateObject private var persistentStore = PersistentStore.shared var body: some Scene { WindowGroup { ContentView() .environment(.managedObjectContext, persistentStore.context) } } The PersistentStore class is a set up as a singleton to load the NSPersistentCloudKitContainer. That code is fairly boiler plate so I won't post it but can upon request. Using a similar pattern in WidgetKit and SwiftUI I currently have this; @main struct WidgetRunPlanner: Widget { @StateObject private var persistentStore =
Topic: App & System Services SubTopic: General Tags:
Aug ’20
Reply to Check Data Re-Sync on App Reinstall with CloudKit (+SwiftUI)
I'm using an almost identical CoreData stack as to what was shown in the WWDC 2019 Posts demo app. Here's the code: import Foundation import CoreData // MARK: - Core Data Stack /** The main Core Data stack setup including history processing./ class CoreDataStack { tt/** ttttA persistent container that can load cloud-backed and non-cloud stores. tt */ ttlazy var persistentContainer: NSPersistentCloudKitContainer = { tttt tttt// Create a container that can load CloudKit-based stores ttttlet container = NSPersistentCloudKitContainer(name: MyCoreDataApp) tttt tttt// Enable history tracking and remote notifications ttttguard let description = container.persistentStoreDescriptions.first else { ttttttfatalError(###(#function): Failed to retrieve a persistent store description.) tttt} ttttdescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) ttttdescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) tttt ttttcontainer.loadPer
Replies
Boosts
Views
Activity
Jun ’20
Reply to Restart sync when using NSPersistentCloudKitContainer
With the following code I'm successfully turning On or Off sync between CoreData and CloudKit. I have iCloudSync saved in UserDefault / @AppStorage and controlled with a toggle switch in my app settings. This line is what turn it off description.cloudKitContainerOptions = nil, I hope it helps. class CoreDataManager: ObservableObject{ // Singleton static let instance = CoreDataManager() private let queue = DispatchQueue(label: CoreDataManagerQueue) @AppStorage(UserDefaults.Keys.iCloudSyncKey) private var iCloudSync = false lazy var context: NSManagedObjectContext = { return container.viewContext }() lazy var container: NSPersistentContainer = { return setupContainer() }() func updateCloudKitContainer() { queue.sync { container = setupContainer() } } func setupContainer()->NSPersistentContainer{ let container = NSPersistentCloudKitContainer(name: YourCoreDataContainerName) guard let description = container.persistentStoreDescriptions.first else{ fatalError(###(#function): Failed to retrieve a persis
Replies
Boosts
Views
Activity
Jun ’24
Reply to How to read/write to App1’s database from App2?
OK, I've solved my issue. 1st of all, defining 2 NSPersistence : ObservableObjects most definitely wasn't the way to go: @StateObject var app1DB = PersistenceApp1.shared @StateObject var app2DB = PersistenceApp2.shared I just needed one: @StateObject var persistence = Persistence.shared deeje's answer pointed me in the right direction, but what was still missing for me were the following 3 key ideas: container's name: is just the name of the .xcdatamodeld - and that this has nothing to do with what I expected (ie, that it was somehow related to my CloudKit container ids “iCloud.com.company.App1”) container = NSPersistentCloudKitContainer(name: Model) Within Model.xcdatamodeld I needed to define 2 separate configurations - with each configuration holding the Entities that are held within the the CloudKit containers: App1Config - holds the Entity from iCloud.com.company.App1, and App2Config - holds the Entity from iCloud.com.company.App2 I needed 2 store descriptions for each app, and to specify the sq
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’22
How to save an audio file using Core Data + CloudKit?
I am transitioning to using CloudKit for syncing, using NSPersistentCloudKitContainer to manage syncing. In my app you can record audio, and I've been saving that by saving the file to disc and storing a relative URL to Core Data. How can I get this to work using NSPersistentCloudKitContainer? I read that I shouldn't store large data as a CoreData attribute for performance, but I need the data to sync with CloudKit.
Replies
1
Boosts
0
Views
1.3k
Activity
Feb ’21
Reply to WidgetKit and CoreData/CloudKit
In testing today, syncing in the background with NSPersistentCloudKitContainer seems to be working more reliably with the iOS 16 SDK. The first time you change something on another device it still seems to schedule a task to perform that work with utility priority (via -[NSCloudKitMirroringDelegate checkAndScheduleImportIfNecessary:andStartAfterDate:] which logs Scheduling automated import with activity CKSchedulerActivity priority 2 Utility), so it doesn't execute right away. If you change it again then I'm seeing it does immediately import the two accumulated changes (NSCloudKitMirroringDelegate Beginning automated import - ImportActivity - in response to activity, then -[PFCloudKitImportRecordsWorkItem applyAccumulatedChangesToStore:inManagedObjectContext:withStoreMonitor:madeChanges:error:] followed by NSCloudKitMirroringImportRequest Importing updated records) which triggers NSManagedObjectContextObjectsDidChange, NSPersistentStoreRemoteChange, and NSPersistentCloudKitContainer.eventChangedNotif
Replies
Boosts
Views
Activity
Jun ’22
Reply to CloudKit sync stopped working with error „You can't save and delete the same record"
Thanks for the reply! Firstly, correct, we're using CoreData + CloudKit and mirrored relationships means reflexive relationships (e.g., Article.similarArticles whereby both are of the type Article). Assuming that you are using Data + CloudKit, I am guessing that this can be triggered by your code and data. Regrettably, that doesn't seem to be the case, also given the Delete Rule is Nullify. Digging through our old messages, we found out that we had already reported this very same issue a couple of years ago with a similar data model but where no entity was ever deleted. At that time we filed feedback report 9118745 and we were told that this was likely a bug. it is worth filing a feedback report for the Core Data team Given this seems to be the very same issue, I’ve added the information of this post to our above ticket (and have provided the relevant system diagnose logs, data model, etc. there too). Does your Core Data model indeed has the reflexive relationship? If yes, has it been there for long time, or
Replies
Boosts
Views
Activity
Jan ’25
Reply to WidgetKit and CoreData/CloudKit
Hi cristosv, Thanks for posting your solution to this online. I'm having the same problem, but it would be great it for you could help a little more. For example, all your code is working fine, but I can't seem to figure out how to use my core data entity in a Text() view in my widget. Below is my code, and any help with this or more sample code would be great. Thanks 🙏 import WidgetKit import SwiftUI import Intents import CoreData struct Provider: IntentTimelineProvider { func placeholder(in context: Context) -> SimpleEntry { SimpleEntry(date: Date(), configuration: ConfigurationIntent()) } func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) { let entry = SimpleEntry(date: Date(), configuration: configuration) completion(entry) } func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline) -> ()) { var entries: [SimpleEntry] = [] // Generate a timeline consisting of five entries an
Replies
Boosts
Views
Activity
Aug ’20
CoreData with CloudKit in WidgetKit not working
In my app, I have an NSPersistentCloudKitContainer set up in the following way: let container: NSPersistentCloudKitContainer init() { self.container = NSPersistentCloudKitContainer(name: Model) self.container.persistentStoreDescriptions[0].setOption( true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey } self.container.loadPersistentStores { (_, error) in guard error == nil else { print(error loading store: (error.debugDescription)) return } } self.container.viewContext.automaticallyMergesChangesFromParent = true } When I invoke a fetch request on the context of the container in my iOS target, it works as expected. However, when I perform the same fetch request in my Widget target, it returns an empty array result. In my iOS target, I have Background Modes / Remote Notifications and iCloud / CloudKit capabilities. In my Widget target, I have the iCloud / CloudKit capability. Not sure why it isn't working, so any help would be much appreciated, thanks!
Replies
3
Boosts
0
Views
1.1k
Activity
Sep ’20
Reply to NSBatchInsertRequest
HiI try to use the NSBatchInsertRequest. but the insertResult is nil, and my CoreData is emptyI use the viewContext of the NSPersistentCloudKitContainer.let container = NSPersistentCloudKitContainer(name: CoreDataPerformance) container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError(Unresolved error (error), (error.userInfo)) } }) try container.viewContext.setQueryGenerationFrom(.current) let moc = container.viewContext moc.automaticallyMergesChangesFromParent = true moc.perform { let insertRequest = NSBatchInsertRequest(entity: Client.entity(), objects: clients) let insertResult = try? moc.execute(insertRequest) as? NSBatchInsertRequest if let success = insertResult as? Bool { print(RESULT: (success)) } }This is the error I receive in the console.2020-02-04 18:30:25.800705+0200 CoreDataPerformance[62836:778869] [error] warning: Multiple NSEntityDescriptions claim the NSManagedObject subclass 'CoreDataPerformance.Client' so +entity
Replies
Boosts
Views
Activity
Feb ’20
Receiving NSPersistentStoreRemoteChange notification when app is closed
I use NSPersistentCloudKitContainer to fetch/sync data across multiple devices with the same iCloud account. /// ... container = NSPersistentCloudKitContainer(name: containerName) let description = container.persistentStoreDescriptions.first description?.setOption( true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) description?.setOption( true as NSNumber, forKey: NSPersistentHistoryTrackingKey) let viewContext = container.viewContext viewContext.automaticallyMergesChangesFromParent = true viewContext.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump NotificationCenter.default.addObserver( forName: .NSPersistentStoreRemoteChange, object: container.persistentStoreCoordinator, queue: .main ) { _ in Task { @MainActor [weak self] in // fetch new data and update widgets with it // ... viewContext.fetch ... // WidgetCenter.shared.reloadAllTimelines() } } } /// ... Everything works fine when my app in the foreground. How can I achieve the same when my app is clos
Replies
0
Boosts
0
Views
734
Activity
Oct ’23
Reply to NSPersistentCloudkitContainer Memory Leak -> Crash? (iOS 15 beta 4 & 5)
Sorry, Apple... this is still broken in iOS 15.1 (beta 2) The CPU & RAM usage is still excessive and no syncing occurs at all. I've replied to my TSI in the hope I can get someone to look into this as a matter of urgency. I now have users running iOS 15 who are no longer seeing their data syncing via iCloud, resulting in a terrible user experience, using my app downloaded from the App Store which has been unchanged since iOS 14. Whatever Apple did in iOS 15 beta 4 to NSPersistentCloudKitContainer, they broke it badly. Maybe users who don't have complex databases aren't seeing this problem, but the whole point of NSPersistentCloudKitContainer is to sync a Core Data store with complex relationships (and besides, it works just fine on iOS 13 & iOS 14!). My testing setup Monterey (beta 8) Xcode 13 (13A233) non-beta Testing on iPhone 13 Pro with iOS 15.1 (beta 2) Preparation Deleted iCloud data for my app Deleted my app from the device (App Store download) Rebooted device Reset the iCloud
Replies
Boosts
Views
Activity
Sep ’21
Reply to MacOS CloudKit production environment is not working properly
I have recently been experiencing issues in the Production Environment as well, although I cannot confirm if it is the same situation. My app is Mac only. I am adding iCloud support to an existing app that is already on the Mac App Store. I am testing such support via TestFlight builds. I am not using SwiftData but traditional Core Data with NSPersistentCloudKitContainer. – When making use of the Production Environment, only partial synchronization took place. This has not been an issue when run in the Development Environment. This occurred multiple times even when testing using accounts with different App IDs. My only thought was that perhaps iCloud also needed to be enabled as a Capability in Certificates, Identifiers & Profiles. That did not end up being the case. However, I was surprised to see that two iCloud Containers were enabled for this app even though only one was selected for the target in Xcode. After removing the unused container from the list and saving, I performed the following a
Replies
Boosts
Views
Activity
Nov ’24
Reply to Core Data CloudKit stops syncing after incomprehensible archive error
This error message your post provided indicates that Core Data failed to unarchive the import request (NSCloudKitMirroringImportRequest). Archiving / unarchiving an import / export request is a Core Data internal logic, and so I agree your assessment that it is not about your code. The feedback report you filed (FB10392936) doesn't mention the error message, and so I'd suggest that you file a new one to specifically report the error – If you do so, please share your report ID here for folks to track. Regarding FB10392936, you most likely hit CloudKit throttles. For more information of this topic, see the following documentations: TN3162: Understanding CloudKit throttles Understand system throttles. When uploading a big data set and hitting CloudKit throttles, the only thing you can do is to lower the CloudKit operation rate. When using Core Data + CloudKit, however, you don't control how NSPersistentCloudKitContainer synchronizes data. Based on today's API, the only thing you can do is to somehow con
Replies
Boosts
Views
Activity
Oct ’24
Reply to Access Core App Data from IOS widget
I wanted to give this thread a bump because I too am facing the same issue. The proposed answer from rr0924, and the referenced article from Antoine van der Lee, does not work for me either. To inject my CoreData model into the Widget extension one failing attempt I've tried was to use a similar method in my iOS app and watchOS companion app. For example this code will allow proper access to CoreData from iOS and watchOS; @main struct RunRosterApp: App { @Environment(.scenePhase) private var scenePhase @StateObject private var persistentStore = PersistentStore.shared var body: some Scene { WindowGroup { ContentView() .environment(.managedObjectContext, persistentStore.context) } } The PersistentStore class is a set up as a singleton to load the NSPersistentCloudKitContainer. That code is fairly boiler plate so I won't post it but can upon request. Using a similar pattern in WidgetKit and SwiftUI I currently have this; @main struct WidgetRunPlanner: Widget { @StateObject private var persistentStore =
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’20
[Core Data + CloudKit] How to exclude one model from being synced with the cloud?
I'm using NSPersistentCloudKitContainer to sync my Core Data stack with iCloud. I have one model that I want to be local to the device - how would I exclude that model from being synced while making sure it is saved to the device?
Replies
1
Boosts
0
Views
1.5k
Activity
Feb ’21