ios 如何删除文件Xcode的引用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5545171/
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
How to remove reference of file Xcode?
提问by A Salcedo
I had removed some files from my iOS project a while back and thought they had been completely deleted. After a long time I created another class which unfortunately had the same name as one of those that I had removed from my project (but the reference nor the file had been removed).
不久前我从我的 iOS 项目中删除了一些文件,并认为它们已被完全删除。很长一段时间后,我创建了另一个类,不幸的是,它与我从项目中删除的类同名(但引用和文件都已删除)。
To make the long story short, my project tried using the reference to the old file, so I went through finder to delete the conflicting files. That solved the issue of which class was being reference. But the reference to the deleted files cause a warning in Xcode giving me a Missing File message.
长话短说,我的项目尝试使用对旧文件的引用,所以我通过 finder 删除了冲突的文件。这解决了哪个类被引用的问题。但是对已删除文件的引用会导致 Xcode 中出现警告,给我一条 Missing File 消息。
Does anyone know how I can remove the old references in order to get rid of this warning?
有谁知道如何删除旧引用以消除此警告?
回答by A Salcedo
Since the reference to those files needed to be removed, I tried creating the files again under the same name as those that I had removed manually and deleted them again through Xcode and selected remove references from the pop up.
由于所需要这些文件的引用被删除,我试图以相同的名称为那些我曾手动删除再创建文件,并通过Xcode中再次删除它们,然后从弹出选择删除引用。
回答by Fjohn
After removing a subproject, the framework was always referenced in my code. To remove this framework I had to do these steps:
删除子项目后,我的代码中始终引用了该框架。要删除此框架,我必须执行以下步骤:
- remove subproject (reference)
- clean project
- close xcode
remove all derived and cached data with this script run in applescript tool :
tell application "Terminal" do script "rm -frd ~/Library/Developer/Xcode/DerivedData/*" do script "rm -frd ~/Library/Caches/com.apple.dt.Xcode/*" end tell
- 删除子项目(参考)
- 清洁工程
- 关闭 xcode
使用在 applescript 工具中运行的此脚本删除所有派生和缓存的数据:
tell application "Terminal" do script "rm -frd ~/Library/Developer/Xcode/DerivedData/*" do script "rm -frd ~/Library/Caches/com.apple.dt.Xcode/*" end tell
回答by carlos
In my case, adding and removing the external frameworks and using Clean did not solve the problem. Going to Target > Build Settings > Search paths and removing the offending paths from Framework Search Paths and Library Search Paths did the trick.
就我而言,添加和删除外部框架并使用 Clean 并没有解决问题。转到 Target > Build Settings > Search paths 并从 Framework Search Paths 和 Library Search Paths 中删除有问题的路径就行了。
回答by dalef
I hit the same issue today. Due to git merge issue, I ended up with a image file removed, but reference to it still exists. To clarify, My intention was to remove the image.
我今天遇到了同样的问题。由于 git merge 问题,我最终删除了一个图像文件,但对它的引用仍然存在。澄清一下,我的意图是删除图像。
The simple way to fix this would be using vim, or other text editors
解决此问题的简单方法是使用 vim 或其他文本编辑器
vim PATH_TO_PROJECT/{#projectName}.xcodeproj/project.pbxproj
and do a search on the name of the file you deleted and just delete all search results there.
并搜索您删除的文件的名称,然后删除那里的所有搜索结果。
回答by KarenAnne
To be safe from this error, make sure you Remove Reference
on the file first before making any changes (outside XCode) on that file like deleting in folder, renaming, etc..
为了避免出现此错误,请确保Remove Reference
在对该文件进行任何更改(在 XCode 之外)之前先处理该文件,例如在文件夹中删除、重命名等。
To remove reference, in XCode, right click on the file then Delete
. A pop-up will show asking if you want to move to trash
or remove reference
.
However, that popup won't show if you made any changes before doing Delete on XCode.
要删除引用,请在 XCode 中右键单击该文件,然后单击Delete
. 将显示一个弹出窗口,询问您是否想要move to trash
或remove reference
。但是,如果您在 XCode 上执行 Delete 之前进行了任何更改,则该弹出窗口不会显示。
Just a tip!
只是一个提示!
回答by Emu Malik
Go to Project> Build Phases> Compile Resourcesand select referenced Class and hit "-" .this Will delete reference And now Build Again.
转到Project> Build Phases> Compile Resources并选择引用的类并点击“-”。这将删除引用,现在再次构建。