itenyh
itenyh

Reputation: 1939

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

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?

Upvotes: 31

Views: 15267

Answers (2)

Saladel
Saladel

Reputation: 63

1. Move to Trash

This option removes files and folders from your project and the file system. Choose this option when you no longer need the information in the files.

2. Remove Reference

This option removes files and folders only from your project. Xcode doesn’t remove them from the file system.

Reference: https://developer.apple.com/documentation/xcode/managing-files-and-folders-in-your-xcode-project#

Upvotes: 2

DrummerB
DrummerB

Reputation: 40211

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.

Upvotes: 49

Related Questions