简体   繁体   English

如何删除文件Xcode的引用?

[英]How to remove reference of file Xcode?

I had removed some files from my iOS project a while back and thought they had been completely deleted.不久前我从我的 iOS 项目中删除了一些文件,并认为它们已被完全删除。 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).很长一段时间后,我创建了另一个类,不幸的是,它与我从项目中删除的类同名(但引用和文件都已删除)。

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.长话短说,我的项目尝试使用对旧文件的引用,所以我通过 finder 删除了冲突的文件。 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.但是对已删除文件的引用会导致 Xcode 中出现警告,给我一条 Missing File 消息。

Does anyone know how I can remove the old references in order to get rid of this warning?有谁知道如何删除旧引用以消除此警告?

由于需要删除对这些文件的引用,我尝试以与手动删除的文件相同的名称再次创建文件,然后通过 Xcode 再次删除它们,并从弹出窗口中选择删除引用。

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关闭 xcode
  • remove all derived and cached data with this script run in applescript tool :使用在 applescript 工具中运行的此脚本删除所有派生和缓存的数据:

     tell application "Terminal" do script "rm -frd ~/Library/Developer/Xcode/DerivedData/*" do script "rm -frd ~/Library/Caches/com.apple.dt.Xcode/*" end tell

In my case, adding and removing the external frameworks and using Clean did not solve the problem.就我而言,添加和删除外部框架并使用 Clean 并没有解决问题。 Going to Target > Build Settings > Search paths and removing the offending paths from Framework Search Paths and Library Search Paths did the trick.转到 Target > Build Settings > Search paths 并从 Framework Search Paths 和 Library Search Paths 中删除有问题的路径就行了。

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.由于 git merge 问题,我最终删除了一个图像文件,但对它的引用仍然存在。 To clarify, My intention was to remove the image.澄清一下,我的意图是删除图像。

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.并搜索您删除的文件的名称,然后删除那里的所有搜索结果。

转到Project > Build Phases > Compile Resources并选择引用的类并点击“-”。这将删除引用,现在再次构建。

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..为了避免出现此错误,请确保在对该文件进行任何更改(在 XCode 之外)之前先Remove Reference该文件的Remove Reference ,例如在文件夹中删除、重命名等。

To remove reference, in XCode, right click on the file then Delete .要删除引用,在 XCode 中,右键单击该文件,然后单击Delete A pop-up will show asking if you want to move to trash or remove reference .将显示一个弹出窗口,询问您是要move to trash还是remove reference However, that popup won't show if you made any changes before doing Delete on XCode.但是,如果您在 XCode 上执行 Delete 之前进行了任何更改,则该弹出窗口不会显示。

Just a tip!只是一个提示!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM