Originally created by @andriichernenko on GitHub (Oct 5, 2016).
Extension of the compiled CoreData model file CoreStore tries to find on initialization is hardcoded as momd (see NSManagedObjectModel+Setup.swift):
@nonobjc
internal static func fromBundle(_ bundle: Bundle, modelName: String, modelVersionHints: Set<String> = []) -> NSManagedObjectModel {
guard let modelFilePath = bundle.path(forResource: modelName, ofType: "momd") else {
CoreStore.abort("Could not find \"\(modelName).momd\" from the bundle. \(bundle)")
}
// ...
However, in some cases the model file has extension mom, which means that CoreStore is unable to find the model and fails.
Originally created by @andriichernenko on GitHub (Oct 5, 2016).
Extension of the compiled CoreData model file CoreStore tries to find on initialization is hardcoded as `momd` (see `NSManagedObjectModel+Setup.swift`):
```
@nonobjc
internal static func fromBundle(_ bundle: Bundle, modelName: String, modelVersionHints: Set<String> = []) -> NSManagedObjectModel {
guard let modelFilePath = bundle.path(forResource: modelName, ofType: "momd") else {
CoreStore.abort("Could not find \"\(modelName).momd\" from the bundle. \(bundle)")
}
// ...
```
However, in some cases the model file has extension `mom`, which means that CoreStore is unable to find the model and fails.
adam
added the wontfix label 2025-12-29 15:24:14 +01:00
The momd and mom files are different things. The momd file is actually a container that contains all version models, and each model version data are in their respective mom files. See the lower part of the NSManagedObjectModel+Setup.swift's fromBundle(...) method:
This part iterates all mom files from inside the momd directory.
@JohnEstropia commented on GitHub (Oct 6, 2016):
Hi
The `momd` and `mom` files are different things. The momd file is actually a container that contains all version models, and each model version data are in their respective mom files. See the lower part of the `NSManagedObjectModel+Setup.swift`'s `fromBundle(...)` method:
``` swift
// ...
var modelVersionFileURL: NSURL?
for modelVersion in modelVersions {
let fileURL = modelFileURL.URLByAppendingPathComponent("\(modelVersion).mom", isDirectory: false)
```
This part iterates all mom files from inside the momd directory.
@deville Just to make sure, are you actually seeing a case where the .mom files are outside the .momd directory? If so, please tell which iOS version you are seeing this and if you have any idea how the file structure was changed.
@JohnEstropia commented on GitHub (Oct 6, 2016):
@deville Just to make sure, are you actually seeing a case where the `.mom` files are _outside_ the `.momd` directory? If so, please tell which iOS version you are seeing this and if you have any idea how the file structure was changed.
@andriichernenko commented on GitHub (Oct 6, 2016):
@JohnEstropia Yes, I actually had a mom file outside the momd.
I am using the latest versions of Xcode and iOS. The model files Xcode 8 creates have extension xcdatamodeld and they get compiled into momd. However, I copied the model from an old project, and it had extension xcdatamodel which was compiled into mom. So that's how I ended up with a separate mom file in the bundle.
@andriichernenko commented on GitHub (Oct 6, 2016):
@JohnEstropia Yes, I actually had a `mom` file outside the `momd`.
I am using the latest versions of Xcode and iOS. The model files Xcode 8 creates have extension `xcdatamodeld` and they get compiled into `momd`. However, I copied the model from an old project, and it had extension `xcdatamodel` which was compiled into `mom`. So that's how I ended up with a separate `mom` file in the bundle.
I think you should fix that on your side. I'm guessing you copied only the contents of your old xcdatamodeld without creating a new xcdatamodeld on your new project. You should put the xcdatamodel in a proper modeld container because versioning in Core Data (not necessarily CoreStore) is managed within that container.
@JohnEstropia commented on GitHub (Oct 6, 2016):
I think you should fix that on your side. I'm guessing you copied only the contents of your old xcdatamodeld without creating a new xcdatamodeld on your new project. You should put the xcdatamodel in a proper modeld container because versioning in Core Data (not necessarily CoreStore) is managed within that container.
@andriichernenko commented on GitHub (Oct 6, 2016):
@JohnEstropia Well, yes, I have fixed this, so no problem here.
I'm guessing you copied only the contents of your old xcdatamodeld without creating a new xcdatamodeld on your new project.
No, that's not the case, the xcdatamodel file I copied was not inside xcdatamodeld.
Since new Xcode versions always create models in container, I guess there's no point in modifying the existing model detection behavior. But maybe it would be nice to mention this somewhere in the docs, just in case somebody else runs into this.
@andriichernenko commented on GitHub (Oct 6, 2016):
@JohnEstropia Well, yes, I have fixed this, so no problem here.
> I'm guessing you copied only the contents of your old xcdatamodeld without creating a new xcdatamodeld on your new project.
No, that's not the case, the `xcdatamodel` file I copied was not inside `xcdatamodeld`.
Since new Xcode versions always create models in container, I guess there's no point in modifying the existing model detection behavior. But maybe it would be nice to mention this somewhere in the docs, just in case somebody else runs into this.
Okay, thanks. I wasn't familiar that older Xcode versions allowed creation of standalone xcdatamodels. Will see how to incorporate this in the README (although I feel theres a whole bunch of legacy behavior that CoreStore doesn't handle in the first place)
@JohnEstropia commented on GitHub (Oct 6, 2016):
Okay, thanks. I wasn't familiar that older Xcode versions allowed creation of standalone `xcdatamodel`s. Will see how to incorporate this in the README (although I feel theres a whole bunch of legacy behavior that CoreStore doesn't handle in the first place)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @andriichernenko on GitHub (Oct 5, 2016).
Extension of the compiled CoreData model file CoreStore tries to find on initialization is hardcoded as
momd(seeNSManagedObjectModel+Setup.swift):However, in some cases the model file has extension
mom, which means that CoreStore is unable to find the model and fails.@JohnEstropia commented on GitHub (Oct 6, 2016):
Hi
The
momdandmomfiles are different things. The momd file is actually a container that contains all version models, and each model version data are in their respective mom files. See the lower part of theNSManagedObjectModel+Setup.swift'sfromBundle(...)method:This part iterates all mom files from inside the momd directory.
@JohnEstropia commented on GitHub (Oct 6, 2016):
@deville Just to make sure, are you actually seeing a case where the
.momfiles are outside the.momddirectory? If so, please tell which iOS version you are seeing this and if you have any idea how the file structure was changed.@andriichernenko commented on GitHub (Oct 6, 2016):
@JohnEstropia Yes, I actually had a
momfile outside themomd.I am using the latest versions of Xcode and iOS. The model files Xcode 8 creates have extension
xcdatamodeldand they get compiled intomomd. However, I copied the model from an old project, and it had extensionxcdatamodelwhich was compiled intomom. So that's how I ended up with a separatemomfile in the bundle.@JohnEstropia commented on GitHub (Oct 6, 2016):
I think you should fix that on your side. I'm guessing you copied only the contents of your old xcdatamodeld without creating a new xcdatamodeld on your new project. You should put the xcdatamodel in a proper modeld container because versioning in Core Data (not necessarily CoreStore) is managed within that container.
@andriichernenko commented on GitHub (Oct 6, 2016):
@JohnEstropia Well, yes, I have fixed this, so no problem here.
No, that's not the case, the
xcdatamodelfile I copied was not insidexcdatamodeld.Since new Xcode versions always create models in container, I guess there's no point in modifying the existing model detection behavior. But maybe it would be nice to mention this somewhere in the docs, just in case somebody else runs into this.
@JohnEstropia commented on GitHub (Oct 6, 2016):
Okay, thanks. I wasn't familiar that older Xcode versions allowed creation of standalone
xcdatamodels. Will see how to incorporate this in the README (although I feel theres a whole bunch of legacy behavior that CoreStore doesn't handle in the first place)