Delete an unreferenced image from repository in Xcode

白昼怎懂夜的黑 提交于 2019-12-23 18:42:10

问题


I deleted default.png from my resources folder because I wanted a different image for the loading screen, but I just deleted the reference which was apparently a dumb thing to do. I dragged the new image into resources and tried to change the name to Default.png, but it won't let me, which I think is because the first Default.png is still in the repository somewhere. Anyway, how do I delete that image(and others with which I have probably done the same thing) from the repository when it is no longer visible in xcode?


回答1:


What kind of repository is it? Subversion? Git?

The SCM integration in Xcode is great for checking out files and committing changes without having to leave the IDE, but it's hardly a full-blown GUI front end to either svn or git. It may be possible to fix your mistake by adding the file back to the project and then deleting it in Xcode in such a way that Xcode will remove it from the repository for you, but the simple solution is to just delete the file from the repository yourself by using the appropriate version control command. For example, if you're using Subversion you could:

svn remove default.png

to remove the file from your version of the repository. When you commit your changes, the file will be deleted in that version. (It'll still exist in previous versions -- that's the whole point of SCM, after all.)

After that, you can create the new file and add it to both the project and the repository in the usual way.




回答2:


You need to manually go into your app's file structure and delete the image files themselves. Also, it is usually a good idea to "clean" the app whenever you remove files or references to files from an XCode project, since XCode can be a bit temperamental about removing files; the key combination for this is

Hope this fixes your problem.




回答3:


Clean all targets should work (at least it worked for me). You can try the following:
a) delete the reference from "Copy Bundle resources" of your target
b) delete the app from Simulator/Device
c) clean all targets




回答4:


Caleb is absolutely right. That fixed the problem here as well for the most files.

An easier way to get an overview of the accidentally un-deleted files, is creating a bookmark of the working copy with Versions (SVN Software - in case you use SVN). There you can detect the problematic files grafically and delete them. I always have to do this after restructuring the project folder.



来源:https://stackoverflow.com/questions/6219357/delete-an-unreferenced-image-from-repository-in-xcode

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