“Data Model Version Compile”.. error after upgradi

2020-02-04 05:19发布

问题:

Since upgrading to Lion yesterday (10.6->10.7), I've been unable to compile a project that had no problems compiling prior to the upgrade.

It's not even a recent change to the project that's causing this error: If I checkout from SVN a version of the project from a few days or a week ago, I get the same error whilst building:

"Command /Developer/usr/bin/momc failed with exit code 6", which expands to the following:

Build Error:

DataModelVersionCompile /Users/ian/Library/Developer/Xcode/DerivedData/inventory-gtvznzuhomhlakbdpocaqwnrihhx/Build/Products/Debug-iphonesimulator/inventory.app/inventory.momd inventory/inventory.xcdatamodeld
cd /Users/ian/AppsDev/uk.co.isurvey-inventory/ios/inventory/trunk/inventory
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/usr/bin/momc -XD_MOMC_SDKROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -XD_MOMC_IOS_TARGET_VERSION=4.3 -MOMC_PLATFORMS iphonesimulator -MOMC_PLATFORMS iphoneos -XD_MOMC_TARGET_VERSION=10.6 /Users/ian/AppsDev/uk.co.isurvey-inventory/ios/inventory/trunk/inventory/inventory/inventory.xcdatamodeld /Users/ian/Library/Developer/Xcode/DerivedData/inventory-gtvznzuhomhlakbdpocaqwnrihhx/Build/Products/Debug-iphonesimulator/inventory.app/inventory.momd

2011-07-21 19:24:44.954 momc[4436:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSXMLDocument initWithData:options:error:]: nil argument'
*** First throw call stack:
(
0   CoreFoundation                      0x00007fff8e411986 __exceptionPreprocess + 198
1   libobjc.A.dylib                     0x00007fff8d0d5d5e objc_exception_throw + 43
2   CoreFoundation                      0x00007fff8e4117ba +[NSException raise:format:arguments:] + 106
3   CoreFoundation                      0x00007fff8e411744 +[NSException raise:format:] + 116
4   Foundation                          0x00007fff8c761310 -[NSXMLDocument initWithData:options:error:] + 89
5   momc                                0x0000000102f04a2c momc + 10796
6   momc                                0x0000000102f04fe8 momc + 12264
7   momc                                0x0000000102f058f0 momc + 14576
8   momc                                0x0000000102f03d20 momc + 7456
9   ???                                 0x000000000000000a 0x0 + 10
)
terminate called throwing an exception
Command /Developer/usr/bin/momc failed with exit code 6

Further explanation:

AFAIK, the only difference is that I'm using Lion now, and the Lion version of Xcode 4.1 (where I was using Xcode 4.1 for Snow Leopard prior to this).

I've deleted /Developer/ , I've reinstalled several times, and re-downloaded the App Store Xcode installer too, in case it was corrupt.

If I create a new project using Xcode (and use Core Data, I think that's related to whatever problem there is building my project), it builds and runs fine: maybe there's something I need to do to fix my real project?

Any suggestions would be brilliant! Cheers, Ian

回答1:

I've had the same issue, OS X Lion 10.7.1, Xcode 4.1.

The problem is solved by removing all *.xcdatamodel directories that are not displayed in Xcode from your *.xcdatamodelid directory. These directories appear after *.xcdatamodel renaming in Xcode.

Removing may be done in Terminal, by “Show package contents” menu in Finder or by right-clicking on xcdatamodel in Xcode and selecting "Show in Finder".



回答2:

Restart XCode and delete all the data from the Derive Data Folder.



回答3:

Interestingly I found that I had this scenario after installing a new version of Xcode. It was caused by Xcode running from the mounted DMG. I chased the problem around for a bit until I eventually figured out it was doing the build using the tools on the DMG rather than the files copied to Applications. By ejecting the Xcode DMG it resolved the problem. Thought I'd post this in case it benefits anyone else. I suspect a number of the fixes being posted here and on other threads are working in some cases by chance of a reboot unmounting the DMG.



回答4:

I suddenly had this trouble on my CI after updating OSX (minor update). Jenkins couldn't build any Obj-C projects and always stopped with the same error (not depending on the project/datamodel).

The fix was to simply remove the derivedData folder and reboot the machine.

rm -rf ~/Library/Developer/Xcode/DerivedData/*
sudo reboot