Xcode: Remove reference to files not showing up as option - ios

I meant to add one file to my project and I accidentally added the entire directory.
Yikes!
I realized it immediately and tried to hit cancel to no avail. The entire directory which contains lots of other Xcode projects got added to my xcode project.
I now want to remove all those files. Normally, you delete and it gives the option to remove reference or move to trash. In this case I don't want to move to trash as I don't want to delete the underlying files, only their presence in this project. However, it is not giving me the option to remove references. It is only giving the option to move to trash or cancel.
Can anyone suggest why I am not getting option to remove reference? Or alternatively, can you suggest how to remove all these files without moving them to trash.
Thanks in advance for any suggestions.

The project sub folder you might not be getting the remove reference option since there is no location for it in file inspector, try doing the delete operation on that root folder(of extra files added).
Still if you wont get option here are couple of options:
You can discard your local changes, if your repo is GIT and you are using SourceTree just reset your files or discard also you can do that from XCode > Source Control > Discard All changes
Select that folder in project and in the file inspector track the file path and take backup and then perform delete action with Move to trash option
Or if you don't have further option and not other way to fix, check out the code in new directory and trash the current one.

Related

Xcode 9 - Some folders marked with red text

In my project, there are some folders that have red text.
The project compiles and everything works, but I can't understand why only some folders have red text.
Check this.
It means they are not found on disk where your project believes they should be. Control-click and Show In Finder to see the folder location to locate the file and drag it back in to the project, and delete the bad reference.Missing. Maybe you moved them somewhere without deleting them from the project or something.
Edit: Don't delete it before add it first, and you should save backup from the files in another folder, also you have to use source controls like Bitbucket, GitHub, or GitLab.
The UI error feedback notifies you that the path is not found. You can select a new one using the folder icon in the right panel. In this way, all files in the folder keep the configuration so it is more convenient.
I illustrate it in the above screenshot.

Xcode showing duplicate project

Never seen this before. Xcode is displaying duplicate project although only single exists on the disk. I have tried refreshing the status from Source control and also checked remote repository, only one exists there. When I refer both in Show in finder, both point to the same location. My worry is if the location is same, and I try to delete any of them, the project will be deleted.
Please rename the project and the associated files without Xcode going mental, and without having to manually re-import all files to the project.

Cleaning up empty file references from collaborated Xcode projects

What are these empty shells in my Xcode filesystem and what's the procedure to remove them safely? Also did a search for duplicate refs in the Xcode File Navigator but didn't find any.
Sidenote: Project is collaborated via git and I suspect that has something to do with their presence. Occasionally after merging feature branches we get conflicts in myproject.pbxproj file and must manually resolve conflicts by deleting duplicate file refs so maybe some slipped through. For anyone who's been in a similar mess: what's the standard way to clean it up?
Yes, I was facing the same issue while merging:
It is because of your project.pbxproj file not updated successfully. For each file we add, its reference is added in project.pbxproj file.here, these files is already having entry for your project.pbxproj file(like E00021389E899 if you look closure to your file) and another user also adds the same file then, 2 entries will be there in your project.pbxproj file for the same .h/.m thats why it is showing this error.
For cleanup purpose, you can simply right click and delete that file. There won't be any issue. and also don't forget to update your code regularly. If you ever have conflicts in your project.pbxproj, than you need to resolve it properly or try to get a fresh copy.

Duplicate files in Xcode manager?

I've found that I get duplicate files in the Xcode manager. They appear to point the same file in finder. My first thought is that this was created when one of my colleges was, incorrectly, fixing a conflict in the source control. I'm not sure how to fix the problem. When I try simply deleting a duplicate Xcode crashes. I've filed this buy with apple. However I would like to remedy this problem in the meantime.
Thank You.
I don't see any duplicates in your list. Every class comes with a .h and a .m file (there are exceptions). Long story short, there's not a problem with the image you posted.
Select one of the CMPortfolio.h files and one of the CMPortfolio.m files (one of the references, rather) and press the delete key. When asked whether you want to remove the references or actually move the files to the Trash, choose Remove References. This should remove the duplicate references while not touching the actual files on disk (which allows the remaining reference to each file to be valid).
I had the same problem. That helped me: I moved all duplicated files in some other folder in Finder -> all files in project were red. Then I simply deleted the files from project, copied the files in the project folder and added them to project again.

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?
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.
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.
Go to Project > Build Phases > Compile Resources and select referenced Class and hit "-" .this Will delete reference And now Build Again.
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!

Resources