Hi, I work on a financial app in Brazil and since Beta 1 we're getting several crashes. We already opened a code level support and a few feedback issues, but haven't got any updates on that yet.
We were able to resolve some crashes changing some of our implementation but we aren't able to understand what might be happening with this last one.
This is the log we got on console:
erro 11:55:41.805875-0300 MyApp CoreData: error: Failed to load NSManagedObjectModel with URL 'file:///private/var/containers/Bundle/Application/0B9F47D9-9B83-4CFF-8202-3718097C92AE/MyApp.app/ServerDrivenModel.momd/'
We double checked and the momd is inside the bundle. The same app works on any other iOS version and if we build using Xcode directly (without archiving and installing on an iOS26 device) it works as expected.
Have anyone else faced a similar error? Any tips or advice on how we can try to solve that?
The error message says Core Data failing to load the model, but doesn't provide the reason. To figure out why, you can probably consider the following debugging process:
-
Use lower level APIs, such as
FileManager
, to confirm that the Core Data model is there and valid. -
If step 1 goes well, copy the
.momd
folder out from the app bundle, and check if it is corrupted.
To do step 2, create a brand new Core Data template projet in your Xcode, and then do the following:
- Select the target, and find
Copy Bundle Resources
inBuild Phases
. - Click the
+
button, and then clickAdd Other
. - Pick the the
.momd
folder you got in step 1. - Choose
Create folder references
in the dialog that asks the option for adding files. - Click
Finish
.
With that, afer building your template project, the .momd
folder should be embedded in your app bundle under the Resources
folder.
You can then use the following code to load the model:
if let momdURL = Bundle.main.url(forResource: <YourModelName>, withExtension: "momd") {
let model = NSManagedObjectModel(contentsOf: momdURL)
}
If you can't load the model this way, it is likely that the model is corrupted, and you can review the build process if there is anything wrong.
If you do successfully load the model, then something strange happens. You can consider capturing and analyzing a sysdiagnose to hopefully find more hints about the reason of the error.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.