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
Search results for
NSPersistentCloudKitContainer
589 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hello everyone, I'm currently working on an iOS app using SwiftUI and Core Data, integrating CloudKit for data synchronization. I've set up my Core Data stack with NSPersistentCloudKitContainer, and everything appears to be working correctly locally. However, I'm not seeing any records appearing in the CloudKit Dashboard. This issue started occurring after transferring the Apple Developer account ownership and changing the CloudKit container. Here's a summary of my setup and what I've tried so far: Setup PersistenceController.swift import SwiftUI import Foundation import CoreData import CloudKit class PersistenceController { static let shared = PersistenceController() let container: NSPersistentCloudKitContainer init() { container = NSPersistentCloudKitContainer(name: Model) guard let description = container.persistentStoreDescriptions.first else { fatalError(No Descriptions found) } description.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: iCl
Hello, I'm using CoreData + CloudKit and I am facing the following error 134100 The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store. All my schema updates are composed of adding optional attributes to existing entities, adding non-optional attributes (with default value) to existing entities or adding new entities Basically, only things that lightweight migrations can handle. Every time I update the schema, I add a new model version of xcdatamodel - who only has a single configuration (the Default one). And I also deploy the updated CloudKit schema from the dashboard. It worked up to v3 of my xcdatamodel, but started to crash for a few users at v4 when I added 16 new attributes (in total) to 4 existing entities. Then again at v5 when I added 2 new optional attributes to 1 existing entity. I'm using a singleton and here is the code: private func generateCloudKitContainer() -> NSPersistentCloudKitContainer { let
Today, I'm working without cloudkit (all data are in a local Coredata), with one database on my Xcode project but with 2 containers on app.delegate : one for a test environment : with storeURL ---> test.sqlite one for a production environment : with storeURL --> production.sqlite Everything is ok, the test data, is really separate from production data. Now, I try to use cloudkit functions : I change NSPersistentContainer to NSPersistentCloudKitContainer it's working and I could use data on 2 iPads. BUT if I switch the test to the prod, now the data from test environnement is duplicate on the production environnement. what mistake am I making? How could I use my two storeURL with cloudkit coredata? Thanx for your help.
I have created a core data model in which i add images of binary data type with Allow external storage. I Sync it on iCloud with Cloudkit using NSPersistentCloudKitContainer. When it automatically sync it from cloud to other device or i uninstall the app and re install it. I have a memory crash as follow.<NSSQLSaveChangesRequestContext: 0x281ec8420> , *** NSAllocateMemoryPages(28317598) failed with userInfo of (null)Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** NSAllocateMemoryPages(28317598) failedI got this crash after updating to iOS 13.1 beta 2. I don't get this crash on simulator iOS 13.0 (It sync it succeccfully from cloud in simulator.)
How does one know when the CloudKit data in a CoreData+CloudKit (NSPersistentCloudKitContainer) has been fully synchronized. UseCase would be a user starts the App on a second device, user deletes then reinstalls the App, another User accepts a share and the share needs to sync. Is the containerEventChanged Notification for 'import success' the definitive event? CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _finishedRequest:withResult:](3403): Finished request: 729A742A-7F3B-42F1-B04C-72705D41FFEF with result: storeIdentifier: 79FA5848-A135-41B1-A36A-09F2F914D23D success: 1 madeChanges: 0 error: (null) As the sync could be time-consuming, is there a way to identify a single CloudKit record?
Hi, On iOS 14 beta 1-3 I was happily using a constraint on several entities in NSPersistentCloudKitContainer. The part of the app using this was essentially an RSS reader - two different devices were independently fetching news and no duplicates due to the constraints. Now on iOS14 beta 4 I'm receiving CloudKit integration does not support unique constraints, which means I've had to remove the constraints.. Now the app is subject to CloudKit sync vs RSS import timing issues.. if CloudKit syncs after the RSS import then there are duplicate items. What's the workaround for this please? It really should just work. Thanks, Andy
Your crash report is only partially symbolicated. To be completely clear what happened in your app, you might consider fully symbolicating your report. The details of how to do so is covered in this article. Having said that, your crash report indicates that the main thread (thread 0) was blocked when SwiftUI initialized a tab view (frame 8). Your app got involved into the process (frame 4, 5), and eventually ran into _dispatch_once_wait (frame 3) and __ulock_wait (frame 0): Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_kernel.dylib 0x1df207f70 __ulock_wait + 8 1 libdispatch.dylib 0x196334c3c _dlock_wait + 56 2 libdispatch.dylib 0x196367408 _dispatch_once_wait.cold.1 + 148 3 libdispatch.dylib 0x196334b98 _dispatch_once_wait + 60 4 MyApp 0x10047b7d4 0x100360000 + 1161172 5 MyApp 0x100563524 0x100360000 + 2110756 6 SwiftUI 0x19369cbd4 Tab<>.init<>(_:systemImage:value:content:) + 300 7 MyApp 0x1005628a8 0x100360000 + 2107560 8 SwiftUI 0x1931b5780 TabView.init(sele
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
I am working on an interactive widget and merging changes provided by a user over it with the app. I store my data, using Core Data. However, I noticed an issue with sync between other user's devices after that person made a change over the widget (in my case, it is completing a task). Here is my schema: Main app: it looks for relevant transactions (https://developer.apple.com/documentation/coredata/consuming_relevant_store_changes). When it found that one, the app merges changes: if transaction.author == widget { if let userInfo = transaction.objectIDNotification().userInfo { NSManagedObjectContext.mergeChanges(fromRemoteContextSave: userInfo, into: [taskContext]) } } Widget: If the user clicks on the checkbox in order to complete a task, using an AppIntent class, app creates an identical NSPersistentCloudKitContainer and completes the task. However, in that case, the NSPersistentCloudKitContainer of the widget does not look for changes. That works correctly. However, only in a local enviro
Hi, I'm building a habit tracking app for iOS and macOS. I want to use up to date technologies, so I'm using SwiftUI and SwiftData. I want to store user data locally on device and also sync data between device and iCloud server so that the user could use the app conveniently on multiple devices (iPhone, iPad, Mac). I already tried SwiftData + NSPersistentCloudKitContainer, but I need to control when to sync data, which I can't control with NSPersistentCloudKitContainer. For example, I want to upload data to server right after data is saved locally and download data from server on every app open, on pull-to-refresh etc. I also need to monitor sync progress, so I can update the UI and run code based on the progress. For example, when downloading data from server to device is in progress, show Loading... UI, and when downloading finishes, I want to run some app business logic code and update UI. So I'm considering switching from NSPersistentCloudKitContainer to CKSyncEngine, because it
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
CloudKit
Cloud and Local Storage
SwiftUI
SwiftData
Hello, I'm running into an odd error. I'm trying to add a composite attribute called period to a Core Data Entity named Report, but I'm getting a compile-time error that points to my xcdatamodel file: Report.period cannot use an attribute type of Composite. In my model configuration I have Used with CloudKit box checked. If I uncheck this box, the error goes away and everything builds fine. But the documentation for NSCompositeAttributeDescription says: You may use composite attributes anywhere you use standard attributes, including lightweight migrations and CloudKit, through NSPersistentCloudKitContainer. So it seems like I should be able to use composite attributes in Core Data with CloudKit syncing enabled. What am I missing here? Is this a bug, or am I doing something wrong?
I'm attempting to write to the public container of CloudKit, but I keep getting the error message: CKError 0x281ff9ec0: Network Unavailable (3/NSURLErrorDomain:-1009); The Internet connection appears to be offline. only when I'm accessing the container through the cellular network. When I try on a wifi network, however, it works perfectly fine and can confirm the presence of the uploaded data on the dashboard. There is absolutely nothing wrong with the cellular connectivity of my device. let publicCloudDatabase = CKContainer.default().publicCloudDatabase let operation = CKModifyRecordsOperation(recordsToSave: [exampleRecord], recordIDsToDelete: nil) let operationConfiguration = CKOperation.Configuration() operationConfiguration.allowsCellularAccess = true operationConfiguration.qualityOfService = .userInitiated operation.configuration = operationConfiguration operation.perRecordProgressBlock = {(record, progress) in ttprint(progress) } operation.perRecordCompletionBlock = {(record, error) in ttprint(Upload co
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
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Xcode
Xcode Sanitizers and Runtime Issues
SwiftUI
Core Data
What interfaces do I use to propagate a CloudKit change in a shared zone to a notification/badge to all participants in the shared zone? Assume I have a 'League' that is the root object in a shared zone and that N Players are members of the league. One of the players, the 'organizer', schedules a 'Game' that is open to any of the players. When the organizer creates the game (in the league's shared zone) and it is mirrored in CloudKit, how can the other players see it (as a timely notification)? I already observe .NSPersistentStoreRemoteChange on NSPersistentStoreCoordinator and NSPersistentCloudKitContainer.eventChangedNotification on NSPersistentCloudKitContainer. Are these delivered in the background? Can/Should they generate a 'local/remote' notification for handling at the AppDelegate level? How? Do I need to use a CKDatabaseSubscription looking for CD_Game records directly? (I'd rather not; because then I'd have a potential race between the remote iCloud database(s) and the local CoreData)
I can't seem to figure out how to get a one-to-many relationship working with a NSPersistentCloudKitContainer. Has anyone been able to do this successfully? I see the relationship that is one-to-one on the other end, but not the relationship which is supposed to be many to many.I've been trying to use the information here https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit/creating_a_core_data_model_for_cloudkit#3191035and am unsure if this is a limitation of CloudKit and CoreData, if the data is there and just not showing in the dashboard or any other option.I've put my code here on Github https://github.com/jknlsn/testcloudkit and would love any help or thoughts. I would also be very keen to hear of any better ways to be debugging and visualising this data I am trying to write apart from the CloudKit dashboard, I don't know yet how to retrieve and display the data with SwiftUI.