I'm using NSPersistentCloudKitContainer in an app and was just studying up on how to do some debugging using the CloudKit Dashboard (watching Build Better Apps with CloudKit Dashboard from WWDC17) - in particular, how to look at live and historical server logs. When I go to CloudKit Dashboard > my.app.bundle.id > Development > Logs and select the Live tab, I see the Logs screen with its header, but instead of showing any log entries, it shows a message saying Logged events will automatically appear here as they happen on the server. If I run my app in development mode (e.g. from Xcode) and update entries, I can see the updated records in CloudKit Dashboard, but the Logs screen stays empty. I can't get CloudKit Dashboard to show any logs at all - live or historical, development or production (yes I know we can't see live production logs, but I get the same blank log area when viewing historical logs for time periods when I know there have been many events). The app is in active development an
Search results for
NSPersistentCloudKitContainer
589 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I am using Core Data with CloudKit through NSPersistentCloudKitContainer. When doing the following, all the data disappears: Start my app (iCloud enabled) Create some items in CoreData Quit the app Turn off iCloud for my app in the iPhone's Settings Start the app again All the items added in step 2 are gone after this. When I turn iCloud on again, they reappear. I read through the documentation, but this does not seem to be expected behaviour. Also, the demo app - https://developer.apple.com/documentation/coredata/synchronizing_a_local_store_to_the_cloud for this topic does not seem to have this issue. However, I am building my CoreData-stack in the same way as they do. Searching on the web it seems that several people have the same issue. Did somebody resolve this? I read that one strategy is to swap NSPersistentCloudKitContainer with NSPersistentContainer in case iCloud is turned off - but the demo-app doesn't do this and still keeps the data even when iCloud gets turned off. So there must
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
CloudKit
Core Data
Cloud and Local Storage
Can we access NSPersistentCloudKitContainer in the same way we do from the app, or will we need still need App Groups? I don't think CloudKit containers work with App Groups.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
If you Changed the name of your .xcdatamodel file ensure that the same name you changed it to is used when making your container in AppDelegate.swift as below let container = NSPersistentCloudKitContainer(name: Same Name )
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
The video discusses limits to background pushes. I'm unable to finish developing my app that uses NSPersistentCloudKitContainer on iOS 14 because I believe background push notifications are being limited by the system so I am unable to test how the app behaves when it is suspended and a background push arrives. In fact I cannot get any background pushes to arrive at all, however pushes do arrive when the app is running in the foreground. Is there perhaps a development entitlement or launch param to override all limits so I can finish my app? And if not, can this feature be added please?
In my new SwiftUI app I am using NSPersistentCloudKitContainer API to persist my data and also share it between multiple different devices. I am always using viewContext to fetch or save records, also my Stack consists of two custom configurations where CloudKit is enabled. One for entities to be stored in the CK public database and one for records in the private database. This usually works just fine. I can save or delete records on one device and they appear on the other device. However in some situations, usually after I imported data on device A and use the same device to create a new record I get errors like this when saving context: Error Domain=NSCocoaErrorDomain Code=133020 Could not merge changes. UserInfo={conflictList=( NSMergeConflict (0x28126df40) for NSManagedObject (0x28242eda0) with objectID '0xb76a5d0f17dd5aa9 ' with oldVersion = 33 and newVersion = 34 and old object snapshot = {n id = D1E2B253-723C-406C-8566-2307DA2D5C17;n name = bench;n} and new cached row = {n id = D1E2B253-723C-4
I am trying to build a widget for iOS 14 using WidgetKit and CoreData/CloudKit instance on a new Xcode 12 project. I have added my CoreData's File Target Membership to both my app and widget I have added an App Group to my main App Target. My Persistence.swift looks like this: init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer(name: test-cd) let storeURL = URL.storeURL(for: group.test-data, databaseName: test-cd) let storeDescription = NSPersistentStoreDescription(url: storeURL) container.persistentStoreDescriptions = [storeDescription] 4. My widget looks like this: struct Provider: TimelineProvider { var managedObjectContext : NSManagedObjectContext init(context : NSManagedObjectContext) { self.managedObjectContext = context } ... } @main struct test_widget: Widget { let kind: String = test_widget var persistentContainer = PersistenceController.shared.container var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: Provider(context: persistentContainer.v
Hi, I have.a project that uses CoreData and I want to add some of the data to iCloud to sync with a Watch app and I ticked the option for the Default configuration to use iCloud and It worked but now I don't want to include images in the cloud because it became too large so I Seperated the images into a different data thing and as per instructions here https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit/setting_up_core_data_with_cloudkit I added a configuration Local and Cloud and change the code as below - original lazy var persistentContainer: NSPersistentContainer = { ttlet container = NSPersistentContainer(name: DataModel) ttcontainer.loadPersistentStores(completionHandler: { ttttstoreDescription, error in ttttif let error = error { ttttttprint(Could load data store: (error)) tttt } tt}) ttprint(Loaded data store: DataModel) ttreturn container }() I created two configurations as per the video and ticked use with iCloud on the one I would like to sync with iCloud. n
Not explicitly no, am I supposed to? I saw this reply https://developer.apple.com/forums/thread/122745?answerId=382227022#382227022 which mentions that NSPersistentCloudKitContainer does use a custom merge policy (last writer wins) by default which is what I want.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
My case is exactly like @Michele Longhi's. Except my solution is keeping a singleton of the NSPersistentCloudKitContainer instead of destroying and recreating it multiple times.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
Hi everyone, I'm trying to use in my app core data as persistent storage. In this app it is supposed to have some entities of core data local but also some other synced through iCloud. In the xcdatamodeld, I create two configs that belongs to each type offline(local) and the online(iCloud) but I'm getting a strange error where it says that it can't use the same container name. I don't understand if for each entity I want to be synced on iCloud I need a different container. Also, I do not understand because if I use only iCloud syncing without using any configuration, I can store different entities. Also, if each entity has a 1:1 relationship with the container, why is impossible to delete it, it doesn't make sense. Here is the code I'm using persistentContainer = NSPersistentCloudKitContainer(name: name, managedObjectModel: model) var defaultDirectoryURL: URL var descriptors = [NSPersistentStoreDescription]() for capability in self.dbCapabilities { if capability.cloudEnable { defaultDirectoryURL = NS
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
CloudKit
Core Data
Cloud and Local Storage
There isn't a signing capability for icloud that is available for either the app or watchos extension targets. My end goal is to have the CoreData CloudKit container that is used by both applications to be in sync and fetch / update the models they modify. Here is what I've done so far: Create iOS with watch app cookie cutter app with xcode 12 Add Remote Notification for Background Modes for both the iOS and watch extension targets. Note I CANNOT find anything to do with icloud or cloudkit as a capability to add. Add the persistence context to the iOS App @main struct MyApp: App { tt@Environment(.scenePhase) private var scenePhase tt@StateObject private var persistentStore = PersistentStore.shared ttvar body: some Scene { ttttWindowGroup { ttttttContentView() tttttttt.environment(.managedObjectContext, persistentStore.context) tttt}.onChange(of: scenePhase) { phase in ttttttswitch phase { ttttttcase .active: ttttttttprint(active) ttttttcase .inactive: ttttttttprint(inactive) ttttttcase .background: ttttttttpr
I currently have an app using Core Data in the App Store: the app allows people to record their water and sailing activities (think of it like Strava for sailors). I have not updated the app for 3 years, the app seems to be still working fine on latest iOS versions but I recently planned to improve the app. I am currently working on an update for this app, and need to change the data model and schema. I would like to have an automatic lightweight migration. I renamed some entities, properties and relationships, but I made sure to put the previous ids in the Renaming ID field in the editor. I want to take advantage of the opportunity to sync the updated schema on CloudKit. I followed the instruction on Apple Developer documentation to setup the sync. I also made sure to initialize the schema using initializeCloudKitSchema(). When I visit the dashboard, I see the correct schema. The container is only in development mode, not pushed into production. When I launch the app with a sqlite file generated by the avail
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
CloudKit
Core Data
Cloud and Local Storage
I'm looking for a solution for the next situation: My app uses CoreData with CloudKit mirroring (via NSPersistentCloudKitContainer). In the latest version of my app I made some changes in db schema and created heavyweight core data migration for it. After this migration finishes, I see lots of duplicates for my entities. I think that CloudKit sees migrated container as a completely new one and just tries to download everything from iCloud again. So generally the question is: should I clean my old CloudKit container somehow and just copy all the data from the new, migrated local one, or there is another solution, how to update cloud kit data with new migrated entities? I'm sorry, if this question is stupid, I'm new to cloud kit and used it in totally auto mode, by just replacing NSPersistentContainer with NSPersistentCloudKitContainer (please, see the code here - https://gist.github.com/eiskrenkov/228c6ecb5c1b78ba360838114a7d0911 ), but now this issue happened. Any help, or chunk of code will
I have an app that's built entirely using SwiftUI. It uses NSPersistentCloudKitContainer to ensure that the iOS, watchOS and widgetKit targets all have the same fresh data. The problem is, this works well when the target is in the foreground, but once any of them are in the background, those targets serve stale data. As soon as they're brought into the foreground, the data gets merged in and I see the correct data. I can tell that this is the case because I have a background task running and when I read from my entity in the background, it is always stale. Because of this, my widget always shows stale data as well as my watch complications. Here are my findings. iPhone App: Data is only fresh when active, if I try reading from the bg, data is stale Watch App: Same as above WidgetKit: The data is only fresh on launch I don't think this is a bug, I think I'm just missing something in my implementation of Core Data. I know that there's Persistent History Tracking that might be a solution, but that seems