From 7b961fa2497fbad77d06a28ae11132aead9c1a7f Mon Sep 17 00:00:00 2001 From: John Estropia Date: Wed, 1 Feb 2017 19:03:59 +0900 Subject: [PATCH] Display list of model files in bundle when requested modelname is not found --- Sources/Internal/NSManagedObjectModel+Setup.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/Internal/NSManagedObjectModel+Setup.swift b/Sources/Internal/NSManagedObjectModel+Setup.swift index 0d3c686..033f730 100644 --- a/Sources/Internal/NSManagedObjectModel+Setup.swift +++ b/Sources/Internal/NSManagedObjectModel+Setup.swift @@ -39,7 +39,10 @@ internal extension NSManagedObjectModel { guard let modelFilePath = bundle.path(forResource: modelName, ofType: "momd") else { // For users migrating from very old Xcode versions: Old xcdatamodel files are not contained inside xcdatamodeld (with a "d"), and will thus fail this check. If that was the case, create a new xcdatamodeld file and copy all contents into the new model. - CoreStore.abort("Could not find \"\(modelName).momd\" from the bundle. \(bundle)") + let foundModels = bundle + .paths(forResourcesOfType: "momd", inDirectory: nil) + .map({ ($0 as NSString).lastPathComponent }) + CoreStore.abort("Could not find \"\(modelName).momd\" from the bundle \"\(bundle.bundleIdentifier ?? "")\". Other model files in bundle: \(foundModels.coreStoreDumpString)") } let modelFileURL = URL(fileURLWithPath: modelFilePath)