How to delete an old/unused Data Model Version in Xcode

独自空忆成欢 提交于 2019-11-26 10:07:44

问题


How can I delete an old Data Model in Xcode? The option is disabled on the menu. (The models I want to delete have not been released to the public - they are interim development models.)


回答1:


It's a hack, but this worked for me:

  1. Set the Current version of the model in Xcode to one that you want to keep
  2. Remove the .xcdatamodeld from your project (Right-click -> Delete -> Remove Reference Only)
  3. Show the contents of the .xcdatamodeld package in the Finder (Right-click -> Show Package Contents)
  4. Delete the .xcdatamodel file(s) that you don't want anymore
  5. Re-add the .xcdatamodeld file to your project

This eliminates the need to manually modify any of the project metadata files.




回答2:


I've just found the need to do this. I created a new model version then realised I didn't need it after all. I was surprised to find there was no way of deleting it (that I could find) from Xcode. Still, to remove it I did the following:

First I made sure it wasn't my current model version. Then I went to Finder and found my *.xcdatamodeld file. Right click and Show Package Contents on that. In there you will find the actual model file and can delete it.

This still doesn't remove it from Xcode and it will show red in the Files and Groups. To stop this from happening go back to Finder and Show Package Contents on your main *.xcodeproj file (you may want to make sure you have a backup of this first). In there open up and edit project.pbxproj do a find on your model version name, in my case "interval 8". For me it appeared on two separate lines. I removed these lines and now it's completely removed from Xcode.




回答3:


My answer is not issue-specific at all but it's quick and works. For those using git. You can just discard unstaged changes.

git stash save --keep-index

Then you can drop that stash with a git stash drop command if you like.



来源:https://stackoverflow.com/questions/7708392/how-to-delete-an-old-unused-data-model-version-in-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!