Posts

Post not yet marked as solved
4 Replies
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.