简体   繁体   中英

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

由于需要删除对这些文件的引用,我尝试以与手动删除的文件相同的名称再次创建文件,然后通过 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

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.

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.

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

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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