You need to create a custom Core Data class and inject it into ContentView() I don‘t have a default file at hand but you can inject it like below let context = PersistentCloudKitContainer.persistentContainer.viewContext tt ContentView().environment(.managedObjectContext, context) Below my CloudKitContainer but you can simply change that to a regular PersistentContainer class import CoreData public class PersistentCloudKitContainer { tt tt// MARK: - Define Constants / Variables ttpublic static var context: NSManagedObjectContext { ttttreturn persistentContainer.viewContext tt} tt tt// MARK: - Initializer ttprivate init() {} tt tt// MARK: - Core Data stack ttpublic static var persistentContainer: NSPersistentCloudKitContainer = { tt ttttlet container = NSPersistentCloudKitContainer(name: Container_Name) ttttcontainer.loadPersistentStores(completionHandler: { (storeDescription, error) in ttttttif let error = error as NSError? { ttttttt ttttttttfatalError(Unresolved error (error), (error.userInf
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: