Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift CoreData EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

I'm trying to use CoreData but whenever I try to store an object, I have been getting the EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) error. What might be causing this error? As a side note, I did not initially create my project intending to use CoreData so CoreData was something I added onto my project later (I don't know if this might be what's causing the problem).

    lazy var managedObjectModel: NSManagedObjectModel = {
        // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
        let modelURL = NSBundle.mainBundle().URLForResource("repliaoutput", withExtension: "momd")!
        return NSManagedObjectModel(contentsOfURL: modelURL)! //this line is where the EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) error is
    }()
like image 388
spotatoz Avatar asked Jan 27 '26 15:01

spotatoz


1 Answers

Remove repliaoutput.xcdatamodel from your project tree, then drag and drop repliaoutput.xcdatamodeld (note the final "d") into your project. Clean, build and it should run like a charm.

like image 128
rjobidon Avatar answered Jan 30 '26 06:01

rjobidon