Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete .xcdatamodel file from Xcode?

Tags:

I made a lightweight migration that I decided I don't want anymore. Is there any way to just delete the file? I've already changed the current model version to the one before it, and the app runs. However, when I right-click on the .xcdatamodel file in the Xcode file viewer, "Delete" is greyed-out. I also tried to remove the file from Finder, but it keeps the file in Xcode, redded-out.

Is there any way to fix this?

like image 943
aopsfan Avatar asked Dec 27 '11 21:12

aopsfan


1 Answers

Yes - having done this a lot, to my knowledge the only way is to open up YourProject.xcodeproj/project.pbxproj in your favourite raw text editor (vim ftw!), and search for and remove both instances of the offending model file. Ie:

D6A5760112F22213004DEDCE /* MyModel.xcdatamodeld */ = {   isa = XCVersionGroup;   children = (     D6EDB44614ED9D7E00C02938 /* MyModel-V12.xcdatamodel */,     D6931E6214D78135007F0E03 /* MyModel-V11.xcdatamodel */,     D61403DD14B7857100323E6D /* MyModel-V10.xcdatamodel */,     D675476B149BD1F3007C160C /* MyModel-V9.xcdatamodel */,     D6199DD5143DE428002869C1 /* MyModel-V8.xcdatamodel */,   );   currentVersion = D6EDB44614ED9D7E00C02938 /* MyModel-V12.xcdatamodel */;   name = MyModel.xcdatamodeld;   path = aPath/MyModel.xcdatamodeld;   sourceTree = "<group>";   versionGroupType = wrapper.xcdatamodel; }; 

So in this case, I go hunting for the two instances of D6199DD5143DE428002869C1 and delete them both from the project file, and bang: Bob's my uncle. Also - you can reorder that chunk of children above in case you want the current one higher.

After I do that, I typically execute a manual source repo delete command on just the model-V8 dir too.

like image 96
Scott Corscadden Avatar answered Oct 04 '22 21:10

Scott Corscadden