Overview:
I have a workspace containing the following structure:
Workspace:
-- SomeApp
-- SomeFramework
---- DataService.swift
---- FrameworkModel.xcdatamodeld
SomeFramework has been added (Embeded & Sign) to SomeProject.
Current Behaviour:
- The app is crashing when I try to print
persistentContainer.viewContext - There is no Sqlite file being created.
- However I am able to access other classes defined in the
SomeFramework
Questions:
- How can I access the DataModel defined in the framework?
DataService.swift:
import Foundation
import CoreData
public class DataService {
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "FrameworkModel")
container.loadPersistentStores { description, error in
if let error = error {
fatalError("Unable to load persistent stores: \(error)")
}
}
return container
}()
public init() {
print(persistentContainer.viewContext) //Crashes here because "Failed to load model named FrameworkModel"
}
}