What's the difference between Xcode's move to trash and remove reference?

itenyh picture itenyh · May 24, 2012 · Viewed 11.5k times · Source

When I want to delete file in Xcode. Between "move to trash" and "remove reference" which one should I choose?

I always choose move to trash before cause I thought it will definitely delete the real file. But not sure if that's right. So what is the difference between them?

Answer

DrummerB picture DrummerB · May 24, 2012

Xcode stores references to the files that make up your project in the project file, namely, the projectName.xcodeproj file. Theoretically your source and resource files that make up your project could be all over your harddisk; of course that's not a good practice.
So, when you add an existing file to your project, Xcode asks whether you want to copy it into your project's folder, which is usually what you should do. So, when you go to delete a file Xcode will ask you whether you only want to remove the reference from your project (and keep the file wherever it lives on your drive) or if you want to remove the file as well.

Basically if you check "Copy to project" when adding the file, you should chose "Move to Trash" when deleting, otherwise pick "Remove Reference". This latter option will leave the file in place and just remove the reference to it.