12

Whenever I build my project, I'm getting the error:

Command /Developer/usr/bin/momc failed with exit code 1

I've read posts here about deleting extraneous Data Model versions as a fix, and nothing works. I'm stumped because nothing changes the behavior of my Build: It always fail with the above error code, regardless of whether I actually have CoreData model files or not.

What I did to cause this error: Switched to a versioning model

What I tried:

  • Removing new version of Data model
  • Removing any old versions of Data model
  • Removing entire versioning model and using previous version from Git
  • Completely deleting any files or references to .xcdatamodel files (no coredata at all)

I've built clean between each attempt, and restarted XCode multiple times. Always the "exit code 1" error with momc.

beeudoublez
  • 1,222
  • 1
  • 12
  • 27
  • 3
    SOLVED: Open up the .pbxproj file and manually remove *all* references to .xcdatamodel. Re-open XCode, Build Clean....and then drop in your older version of .xcdatamodel – beeudoublez Oct 09 '11 at 18:09
  • Thanks, excellent advice, had the same problem when migrating from XCode4.1 to 4.2 – DaGaMs Oct 11 '11 at 08:06
  • Awesome DaGaMs, I was hoping this would be found by others, even though it wasn't marked 'Solved' in the traditional way. Thanks for upvoting. – beeudoublez Oct 12 '11 at 15:04
  • Closing Xcode and reverting via Git, then opening, cleaning and building solved the problem. I was then able to version normally. – David James Jun 04 '15 at 17:45

2 Answers2

19

Open up the .pbxproj file and manually remove all references to .xcdatamodel. Re-open XCode, Build Clean....and then drop in your older version of .xcdatamodel

Chadwick
  • 12,555
  • 7
  • 49
  • 66
beeudoublez
  • 1,222
  • 1
  • 12
  • 27
16

For me the issue wasn't within the .pbxproj file.

Find the xcdatamodel file in finder. Option click and open package contents. Check to see if there are multiple versions inside that you don't recognise.

I was expecting only one version. A second version some how came about and xcode wasn't registering it.

I removed the second version and it's working fine now.

  • This was what happened to me. I had created a version to test, then I discarded it via source control (mercurial to be specific). As a result the file was not accounted for in the project, but was still left over in the package which must have been causing the crash. – Rembrandt Q. Einstein Jun 27 '14 at 22:00
  • Hey Hi, I have only one copy of xcdatamodel file. But still I am getting error – Avinash Jadhav Aug 09 '16 at 14:39