Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

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
Reply to CloudKit + CoreData: Now how do I take advantage of CloudKit user-to-user sharing without losing CoreData + CloudKit synchronization?
I've tried to implement some code for sharing manually with working CloudKit + CoreData mirroring. I've stuck on the parent records (I have one-to-many relationship and child records need to be shared when parent record is shared) and here is why. I've implemented code that is setting parent records for each NSManagedObject's CKRecord, syncing works well, but it causes huge troubles like: I call my setParentRecords among other places from NWPathMonitor's pathUpdateHandler (literally when internet restored), and fetching NSManagedObjects that's CKRecords if any don't have parent on the server yet. Apple's NSCloudKitMirroringDelegate is doing the same also on internet restore. And my any fetching at this second causes crash of Mirroring. Mirroring do not work since this point and says probably no internet each time! I could not beat that problem and I am afraid that will have to implement whole sync by myself, even for privateDatabase just because of such bugs (and no any completion handlers in NSPersistentCloudKitContainer
Jul ’20
Reply to CoreData in Swift Packages
Hi, This post helped me so I figured I'd post a working example of the core data model that I am successfully using in a new Swift Package. This code below is from the lazy var persistentContainer: let bundle = Bundle.module let modelURL = bundle.url(forResource: ModelName, withExtension: .momd)! let model = NSManagedObjectModel(contentsOf: modelURL)! let container = NSPersistentCloudKitContainer(name: ModelName, managedObjectModel: model) You can make the model a lazy var. I call it from the host app below: NavigationLink(destination: GenericListCDView() .environment(.managedObjectContext,ModelCDStack.shared.context) , label: { Text(My List) }) Hope this helps.
Jul ’20
NSCloudKitMirroringDelegate "Never successfully initialised" error
After single attempt to fetch context on persistentContainer right after internet was restored (NWPathMonitor update handler), CoreData+CloudKit mirroring stuck and messaging that no internet, and cannot initialise. All CloudKit requests work perfect, but CloudKitMirroring cannot do sync, only app restart helps. Have no idea how simple fetch can kill CoreData mirroring... It happens each time I fetch on internet restore (I have to do that, to upload parent records to CloudKit manually as Apple did not implemented that in NSPersistentCloudKitContainer, all my records must have parents in order to share them). 2020-07-24 19:36:25.309059+0300 Grocery List[1045:148713] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate requestAbortedNotInitialized:]1379: <NSCloudKitMirroringDelegate: 0x281e048f0> - Never successfully initialized and cannot execute request '<NSCloudKitMirroringDelegateSerializationRequest: 0x283c6cec0> B20F9DB7-9600-4456-B682-056F4849FE4D resultType: Records resul
2
0
1.4k
Jul ’20
Reply to CloudKit + CoreData: Now how do I take advantage of CloudKit user-to-user sharing without losing CoreData + CloudKit synchronization?
Yes, It is not supported and you can use it, but have to write some extra code can be read as either saying the same thing, or contradicting each other, and after spending some hours looking through forums and documentation, without more context your intended meaning of NSPersistentCloudKitContainer does not yet support sharing isn't obvious to me. Contributing to my confusion, about a year ago the answer given included - https://developer.apple.com/forums/thread/117938?answerId=376835022#376835022: NSPersistentCloudKitContainer does not support sharing.... and As others have (correctly) pointed out, NSPersistentCloudKitContainer maintains a specific zone in the private database, and therefore will never see any shared zones owned by other users. Three weeks ago this answer - https://developer.apple.com/forums/thread/651651?answerId=616641022#616641022 also seems to say no: NSPersistentCloudKitContainer only supports the private database and the public database. If you wan
Jul ’20
How to extend NSPersistentCloudKitContainer to upgrade generated CKRecords
Hi, I am developing sharing feature with already working mirroring and need to set parentRecord to child items. I want to extend NSPersistentCloudKitContainer (or any it's component used for mirroring) in some way to get access to CKRecords it is creating before container will push records to the server. Goal — I want to set CKRecord.parent right before CKModifyRecordsOperation fires somewhere in NSPersistentCloudKitContainer. Reason — NSPersistentCloudKitContainer do not handle parent records by itself.
0
0
511
Jul ’20
NSPersistentCloudkitContainer makes Cloudkit Metadata Migrator
Hello. Now I'm trying to add Cloudkit + iCloud synchronization feature with NSPersistentCloudkitContainer. It's super easy and cool. However, When I tried some test with large data, there is expensive cost task on every app launch time. Actually, this task also executed on small dataset, but its cost increased by increasing local core data storage. This task seems like migration for cloudkit. I guess that this task save additional data on local storage. (I checked this on Settings > General > iPad Storage) This task takes 20 minutes (with 5GB test data, core data storage) on background thread , using full of one core cpu. Importantly, if there is new data to sync, the synchronization starts after this heavy migration task ends. So if user create new data and terminate application before migration ends, that new data never synchronized. Also, if I delete my cloud data on Settings > Account > iCloud > Manage Storgae, my local app storage remain some of data. My all local data to used on
0
0
763
Jul ’20
Reply to CloudKit + CoreData: Now how do I take advantage of CloudKit user-to-user sharing without losing CoreData + CloudKit synchronization?
I'm not sure how to rectify the two answers from Apple. The staff answer reads to me as yes, with some extra work. The engineer answer reads to me as a flat no, don't even try. Can someone please clarify? Does does not yet support sharing mean you literally can't use sharing with NSPersistentCloudKitContainer at all, even with additional code?
Jul ’20
Child records not showing in the Shared Database when sharing the Parent record in CloudKit
I've set up a Core Data mirroring to CloudKit using NSPersistentCloudKitContainer. My simplified data structure consists of List and Item. List have one-to-many relationship items with many Items, Item has parentList property. When I am getting CKRecord associated with List NSManagedObject and sharing it, I expect all child Items to be shared too. I know, I can set parentRecord property for each CKRecord associated with the List childRecord.setParent(parentRecord) But I believe there is some smart way to avoid doing that manually, because everything is mirroring automatically and it looks not nice to start handling each single property manually to only set parentRecord. Is there any way to do that for NSManagedObjects? Because my custom relationship does not mean for CloudKit that the List is parent for the Item.
0
0
529
Jul ’20
Reply to Error while trying to save two records with CKReference to each other
Ok I've narrowed the issue down. If my call to setParent on the Chat object (line 13 above of the first code listing). If I remove this line. Everything works and my two references are saved so each record has a reference to each other. However I believe then that I'm missing the benefits of using setParent? So that when I do an update to a child object things are kept in sync? Or is setParent only to be used when using CoreData/CloudKit syncing that was introduced in 2019 with NSPersistentCloudKitContainer? I'm not using that (as much as I'd like to) because I need to share my records. So I'm doing the Core Data/Cloud Kit syncing myself.
Jul ’20
CoreData: warning: CoreData+CloudKit
I use NSPersistentCloudKitContainer. It seems that it the data synced in iCloud after a few seconds. However, I get the following warnings in the console. I do not understand what is it for. CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(813): <NSCloudKitMirroringDelegate: 0x280b051e0>: Successfully set up CloudKit integration for store: <NSSQLCore: 0x280024a00> (URL: file:///private/var/mobile/Containers/Shared/AppGroup/89D9D17C-03DF-48E4-83C3-DB23A8FE0D6F/TestData.sqlite) CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndScheduleImportIfNecessary:]_block_invoke(2033): <NSCloudKitMirroringDelegate: 0x280b051e0>: Scheduling automated import with activity: Could you please explain what is this warning for and what should I do to fix it?
2
0
1.8k
Jul ’20
CoreData changes made aren’t showing in Data in CloudKit Dashboard
i am using NsPersistentCloudkitContainer with CoreData and CloudKit to manage my database. When I save data to the managedObjectContext I see my data model ‘Post’ added in Schema as a Record Type in the CloudKit Dashboard , but when I go to the Data section I still don’t see any data added. can anyone help why this is happening?
0
0
450
Jul ’20