从 Xcode 的存储库中删除未引用的图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6219357/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Delete an unreferenced image from repository in Xcode
提问by Ryan
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?
我从我的资源文件夹中删除了 default.png,因为我想要一个不同的加载屏幕图像,但我只是删除了引用,这显然是一件愚蠢的事情。我将新图像拖到资源中并尝试将名称更改为 Default.png,但它不会让我这样做,我认为这是因为第一个 Default.png 仍在存储库中的某个地方。无论如何,当它在 xcode 中不再可见时,如何从存储库中删除该图像(以及其他我可能做过同样事情的图像)?
回答by Caleb
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:
Xcode 中的 SCM 集成非常适合在无需离开 IDE 的情况下检查文件和提交更改,但它对于 svn 或 git 来说都不是一个成熟的 GUI 前端。可以通过将文件添加回项目然后在 Xcode 中删除它来修复您的错误,这样 Xcode 就会为您从存储库中删除它,但简单的解决方案是从存储库中删除该文件自己使用适当的版本控制命令。例如,如果您使用 Subversion,您可以:
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.)
从您的存储库版本中删除文件。当您提交更改时,该文件将在该版本中被删除。(它仍然存在于以前的版本中——毕竟,这就是 SCM 的全部意义所在。)
After that, you can create the new file and add it to both the project and the repository in the usual way.
之后,您可以创建新文件并以通常的方式将其添加到项目和存储库中。
回答by mdominick
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
您需要手动进入应用程序的文件结构并自行删除图像文件。此外,每当您从 XCode 项目中删除文件或对文件的引用时,“清理”应用程序通常是一个好主意,因为 XCode 在删除文件方面可能有点脾气暴躁;关键组合是
Hope this fixes your problem.
希望这能解决您的问题。
回答by Tatvamasi
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
清理所有目标应该有效(至少它对我有用)。您可以尝试以下操作:
a) 从目标的“复制捆绑资源”中删除引用
b) 从模拟器/设备中删除应用
c) 清除所有目标
回答by brainray
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.
获得意外未删除文件概览的更简单方法是使用版本(SVN 软件 - 如果您使用 SVN)创建工作副本的书签。在那里,您可以通过图形方式检测有问题的文件并删除它们。在重组项目文件夹后,我总是必须这样做。