如何删除 Xcode 文件的引用?

发布于 2024-10-30 08:35:01 字数 218 浏览 3 评论 0原文

不久前,我从我的 iOS 项目中删除了一些文件,并认为它们已被完全删除。很长一段时间后,我创建了另一个类,不幸的是,它与我从项目中删除的类同名(但引用和文件都已被删除)。

长话短说,我的项目尝试使用对旧文件的引用,所以我通过查找器删除了冲突的文件。这就解决了引用哪个类的问题。但是对已删除文件的引用会导致 Xcode 发出警告,给出“丢失文件”消息。

有谁知道如何删除旧的引用以消除此警告?

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).

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.

Does anyone know how I can remove the old references in order to get rid of this warning?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

源来凯始玺欢你 2024-11-06 08:35:01

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

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.

黑凤梨 2024-11-06 08:35:01

删除子项目后,我的代码中总是引用该框架。
要删除这个框架,我必须执行以下步骤:

  • 删除子项目(参考)
  • 清理项目
  • 关闭 xcode
  • 使用在 applescript 工具中运行的脚本删除所有派生和缓存的数据:

    告诉应用程序“终端”
        执行脚本“rm -frd ~/Library/Developer/Xcode/DerivedData/*” 
        执行脚本“rm -frd ~/Library/Caches/com.apple.dt.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
  • 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
    
流绪微梦 2024-11-06 08:35:01

就我而言,添加和删除外部框架以及使用 Clean 并没有解决问题。前往目标>构建设置>搜索路径并从框架搜索路径和库搜索路径中删除有问题的路径就可以了。

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.

栀梦 2024-11-06 08:35:01

我今天遇到了同样的问题。由于 git merge 问题,我最终删除了一个图像文件,但对它的引用仍然存在。澄清一下,我的目的是删除该图像。

解决此问题的简单方法是使用 vim 或其他文本编辑器

vim PATH_TO_PROJECT/{#projectName}.xcodeproj/project.pbxproj

,搜索您删除的文件的名称,然后删除其中的所有搜索结果。

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.

The simple way to fix this would be using vim, or other text editors

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.

著墨染雨君画夕 2024-11-06 08:35:01

转到项目> 构建阶段 > 编译资源并选择引用的类并点击“-”。这将删除引用,然后再次构建。

Go to Project > Build Phases > Compile Resources and select referenced Class and hit "-" .this Will delete reference And now Build Again.

辞别 2024-11-06 08:35:01

为了避免此错误,请确保在对该文件进行任何更改(在 XCode 之外)之前先对该文件进行删除引用,例如在文件夹中删除、重命名等。

要删除引用,请在 XCode 中,右键单击该文件,然后删除。将显示一个弹出窗口,询问您是否要移至垃圾箱删除引用
但是,如果您在 XCode 上执行“删除”之前进行了任何更改,该弹出窗口将不会显示。

只是一个提示!

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..

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.

Just a tip!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文