Search results for

“NSPersistentCloudKitContainer”

601 results found

Post

Replies

Boosts

Views

Activity

Reply to NSPersistentCloudKitContainer change cloudKitContainerOptions while app is running
I've similar concerns. The contexts from the first container will not be useable (at least in my testing). Short of tearing down the old core data stack, standing up the new one and traversing the view hierarchy to replace all existing managed objects and managed object contexts, there doesn't seem to be a way to toggle sync using NSPersistentCloudKitContainer. Not being able to pause or toggle sync seems to be a real shortcoming with NSPersistentCloudKitContainer. For kicks, I tried just disabling iCloud for the app Settings->AppleID->iCloud->App but that just deleted all the data on the device. I can live with the eventual consistency and not knowing sync progress, but not being able to toggle sync is a show stopper.
Aug ’20
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
NSPersistentCloudKitContainer: Migration failed based on alphabetical order
I added a new Core Data model version, introducing a new entity. Based on the naming of the Entity I get different behaviour: A: If the entity is alphabetically ordered as last entity: Everything works fine. B: There entity is ordered before already existing entities: All records of these existing entities get a new CloudKit id. Resulting in duplicated data and broken relations. In some cases the seem-to-be new insert of these records causes the migration to fail. (Constraint unique violation, reason=constraint violation during attempted migration) My only workaround so far is to just give the entity a different name, to appear last in the list. __ Does anyone else experience this issues? I am not sure if my code could be able to trigger this kind of behaviour. I will try to reproduce it in an empty project, to file a bug report.
4
0
1.1k
Aug ’20
NSPersistentCloudKitContainer and CloudKit for Sharing
Hello,I've tried to figure this out for weeks now, but can't find a solution. I am not very experienced in App Development yet, so maybe it can be solved with little effort and I just don't know how...?I am working on a baby journal app where parents should be able to share a child record together with all its entries (existing ones and ones that are going to be added in the future) to be able to both edit and add and look at entries. So, I need sharing like in the Apple Notes App.I am using core data and the new NSPersistentCloudKitContainer. The core data model consists of a child record and entities that are referencing to the child.I know that at the moment NSPersistentCloudkitContainer doesn't support sharing.I have no clue how to add sharing with CKShare API beside the core data stuff. To have a proper solution, do I need toa) throw away NSPersistentCloudKitContainer and solely base the app on CloudKit API with no core data at all?b) add CloudKit Sharing via CKShare API, exist
4
0
3.5k
Aug ’20
Reply to NSSecureUnarchiveFromData is now necessary for transformable attributes but does not work with Core Data CloudKit?
I was able to remove the warnings by registering a new value transformer. I'm persisting a CLLocation, which conforms to NSSecureCoding. import Foundation import CoreLocation @objc(CLLocationValueTransformer) final class CLLocationValueTransformer: NSSecureUnarchiveFromDataTransformer { static let name = NSValueTransformerName(rawValue: String(describing: CLLocationValueTransformer.self)) override static var allowedTopLevelClasses: [AnyClass] { return [CLLocation.self] } public static func register() { let transformer = CLLocationValueTransformer() ValueTransformer.setValueTransformer(transformer, forName: name) } } Adding CLLocationValueTransformer as the transformer name works without warnings. The value is synced properly via NSPersistentCloudKitContainer, verified on multiple devices.
Aug ’20
[NSPersistentCloudKitContainer][Mac Catalyst specific crash] app is constantly crashing within a minute or two
Core Data, Catalyst, CloudKIt engineers need your assistance. I have an app that uses NSPersistentCloudKitContainer. It works great on iOS, but on the mac (Catalyst), the app is constantly crashing and is unusable. The CloudKit scheduler com.apple.xpc.activity.com.apple.cloudkit.scheduler.com.apple.coredata.cloudkit.activity.export seems to be at fault. It's crashing inside a generic dispatch block, so it's impossible to debug. Found a similar thread: https://developer.apple.com/forums/thread/128131?page=1 This is on Catalina 10.15.5 (19F101). MacBook Pro (Retina, 13-inch, Early 2015) Any ideas on how to debug/solve the root cause of this issue? Here's the image of the crash report (image hosted on imgbb.com): ibb.co nQy6rwm Thread 19 Queue : com.apple.xpc.activity.com.apple.cloudkit.scheduler.com.apple.coredata.cloudkit.activity.export (serial) #0 0x00007fff73de0436 in __xpcactivitydispatchblockinvoke.109.cold.3 () #1 0x00007fff73dde82b in _xpcactivitydispatchblockinvoke.109 () #2 0x000000010040f844
1
0
939
Aug ’20
NSPersistentCloudKitContainer with Mac Catalyst
Hello,I ported the WWDC 2019 NSPersistentCloudKitContainer demo project to Mac Catalyst and it keeps on crashing everytime I run (within a minute or so of the app running). I'm getting the same BAD EXC INSTRUCTION on my Mac Catalyst app as well (which uses NSPersistentCloudKitContainer). Both projects run just fine on iPad and iPhone.Anybody experiencing the same issue? Any help would be appreciated.
6
0
2k
Aug ’20
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 NSCloudKitMirroringExportRequest issues
I'll make a guess you are implementing your App struct as if it were a class and accidentally creating a new instance of NSPersistentCloudKitContainer every time SwiftUI recreates the struct. You could access the persistent container lazy property through a @UIApplicationDelegateDelegateAdaptor so it is only created once. import SwiftUI import CoreData @main struct MasterDetailApp: App { t@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate tt ttvar body: some Scene { ttttWindowGroup { ttttttContentView().environment(.managedObjectContext, appDelegate.persistentContainer.viewContext) tttt} tt} }
Aug ’20
NSPersistentCloudKitContainer stops syncing
I have moved my NSPersistentContainer in my app to an NSPersistentCloudKitContainer to sync data between devices (iPhone, iPad, and Apple Watch supported). Sync works just fine in test & production, but after a few days it will stop working and behave as if each device is using local storage. This continues to happen until I reinstall the app and it syncs again, but only for a short time until it goes back to using local storage again. Does anyone know of a way to debug this?
3
0
893
Jul ’20
Reply to NSPersistentCloudKitContainer change cloudKitContainerOptions while app is running
I've similar concerns. The contexts from the first container will not be useable (at least in my testing). Short of tearing down the old core data stack, standing up the new one and traversing the view hierarchy to replace all existing managed objects and managed object contexts, there doesn't seem to be a way to toggle sync using NSPersistentCloudKitContainer. Not being able to pause or toggle sync seems to be a real shortcoming with NSPersistentCloudKitContainer. For kicks, I tried just disabling iCloud for the app Settings->AppleID->iCloud->App but that just deleted all the data on the device. I can live with the eventual consistency and not knowing sync progress, but not being able to toggle sync is a show stopper.
Replies
Boosts
Views
Activity
Aug ’20
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
Reply to CoreData in Multiplatform App
Thanks @nigelfromtewkesbury that worked for me, too. Also led me to persistence.swift:34 where you can change the name of the data model it looks for: container = NSPersistentCloudKitContainer(name: YourContainerName)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’20
NSPersistentCloudKitContainer: Migration failed based on alphabetical order
I added a new Core Data model version, introducing a new entity. Based on the naming of the Entity I get different behaviour: A: If the entity is alphabetically ordered as last entity: Everything works fine. B: There entity is ordered before already existing entities: All records of these existing entities get a new CloudKit id. Resulting in duplicated data and broken relations. In some cases the seem-to-be new insert of these records causes the migration to fail. (Constraint unique violation, reason=constraint violation during attempted migration) My only workaround so far is to just give the entity a different name, to appear last in the list. __ Does anyone else experience this issues? I am not sure if my code could be able to trigger this kind of behaviour. I will try to reproduce it in an empty project, to file a bug report.
Replies
4
Boosts
0
Views
1.1k
Activity
Aug ’20
NSPersistentCloudKitContainer and CloudKit for Sharing
Hello,I've tried to figure this out for weeks now, but can't find a solution. I am not very experienced in App Development yet, so maybe it can be solved with little effort and I just don't know how...?I am working on a baby journal app where parents should be able to share a child record together with all its entries (existing ones and ones that are going to be added in the future) to be able to both edit and add and look at entries. So, I need sharing like in the Apple Notes App.I am using core data and the new NSPersistentCloudKitContainer. The core data model consists of a child record and entities that are referencing to the child.I know that at the moment NSPersistentCloudkitContainer doesn't support sharing.I have no clue how to add sharing with CKShare API beside the core data stuff. To have a proper solution, do I need toa) throw away NSPersistentCloudKitContainer and solely base the app on CloudKit API with no core data at all?b) add CloudKit Sharing via CKShare API, exist
Replies
4
Boosts
0
Views
3.5k
Activity
Aug ’20
Reply to NSSecureUnarchiveFromData is now necessary for transformable attributes but does not work with Core Data CloudKit?
I was able to remove the warnings by registering a new value transformer. I'm persisting a CLLocation, which conforms to NSSecureCoding. import Foundation import CoreLocation @objc(CLLocationValueTransformer) final class CLLocationValueTransformer: NSSecureUnarchiveFromDataTransformer { static let name = NSValueTransformerName(rawValue: String(describing: CLLocationValueTransformer.self)) override static var allowedTopLevelClasses: [AnyClass] { return [CLLocation.self] } public static func register() { let transformer = CLLocationValueTransformer() ValueTransformer.setValueTransformer(transformer, forName: name) } } Adding CLLocationValueTransformer as the transformer name works without warnings. The value is synced properly via NSPersistentCloudKitContainer, verified on multiple devices.
Replies
Boosts
Views
Activity
Aug ’20
[NSPersistentCloudKitContainer][Mac Catalyst specific crash] app is constantly crashing within a minute or two
Core Data, Catalyst, CloudKIt engineers need your assistance. I have an app that uses NSPersistentCloudKitContainer. It works great on iOS, but on the mac (Catalyst), the app is constantly crashing and is unusable. The CloudKit scheduler com.apple.xpc.activity.com.apple.cloudkit.scheduler.com.apple.coredata.cloudkit.activity.export seems to be at fault. It's crashing inside a generic dispatch block, so it's impossible to debug. Found a similar thread: https://developer.apple.com/forums/thread/128131?page=1 This is on Catalina 10.15.5 (19F101). MacBook Pro (Retina, 13-inch, Early 2015) Any ideas on how to debug/solve the root cause of this issue? Here's the image of the crash report (image hosted on imgbb.com): ibb.co nQy6rwm Thread 19 Queue : com.apple.xpc.activity.com.apple.cloudkit.scheduler.com.apple.coredata.cloudkit.activity.export (serial) #0 0x00007fff73de0436 in __xpcactivitydispatchblockinvoke.109.cold.3 () #1 0x00007fff73dde82b in _xpcactivitydispatchblockinvoke.109 () #2 0x000000010040f844
Replies
1
Boosts
0
Views
939
Activity
Aug ’20
NSPersistentCloudKitContainer with Mac Catalyst
Hello,I ported the WWDC 2019 NSPersistentCloudKitContainer demo project to Mac Catalyst and it keeps on crashing everytime I run (within a minute or so of the app running). I'm getting the same BAD EXC INSTRUCTION on my Mac Catalyst app as well (which uses NSPersistentCloudKitContainer). Both projects run just fine on iPad and iPhone.Anybody experiencing the same issue? Any help would be appreciated.
Replies
6
Boosts
0
Views
2k
Activity
Aug ’20
Reply to CloudKit + CoreData: Now how do I take advantage of CloudKit user-to-user sharing without losing CoreData + CloudKit synchronization?
CKDatabaseScopeShared is not supported with NSPersistentCloudKitContainer?
Replies
Boosts
Views
Activity
Aug ’20
Reply to Required CKRecord Indexes for Core Data with CloudKit
No. NSPersistentCloudKitContainer does not use queries in the private database, only the public.
Replies
Boosts
Views
Activity
Aug ’20
Reply to How to initialize Schema?
https://developer.apple.com/documentation/coredata/nspersistentcloudkitcontainer/3343548-initializecloudkitschemawithopti?language=objc
Replies
Boosts
Views
Activity
Aug ’20
Reply to Why? "CloudKit integration does not support unique constraints"
NSPersistentCloudKitContainer never supported unique constraints. In iOS 14 we made this a lot more obvious.
Replies
Boosts
Views
Activity
Aug ’20
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
Reply to NSCloudKitMirroringExportRequest issues
I'll make a guess you are implementing your App struct as if it were a class and accidentally creating a new instance of NSPersistentCloudKitContainer every time SwiftUI recreates the struct. You could access the persistent container lazy property through a @UIApplicationDelegateDelegateAdaptor so it is only created once. import SwiftUI import CoreData @main struct MasterDetailApp: App { t@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate tt ttvar body: some Scene { ttttWindowGroup { ttttttContentView().environment(.managedObjectContext, appDelegate.persistentContainer.viewContext) tttt} tt} }
Replies
Boosts
Views
Activity
Aug ’20
NSPersistentCloudKitContainer stops syncing
I have moved my NSPersistentContainer in my app to an NSPersistentCloudKitContainer to sync data between devices (iPhone, iPad, and Apple Watch supported). Sync works just fine in test & production, but after a few days it will stop working and behave as if each device is using local storage. This continues to happen until I reinstall the app and it syncs again, but only for a short time until it goes back to using local storage again. Does anyone know of a way to debug this?
Replies
3
Boosts
0
Views
893
Activity
Jul ’20