What's the difference between Xcoce'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?
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.
Not a direct answer to this question, but very good to know. I created a file named Device.swift in my branch and added some code to it. Then my colleague also created the same file Device.swift in his branch and got it merged before I got my chnages merged.
What will happen is that both in my xcodeproj/project.pbxproj file there was something like:
5C5809E72257D81500D4CBB2 /* Device.swift in Sources */
While in the master branch which had his changes, there was:
26E3A7A5226F6E13001B176C /* Device.swift in Sources */
We’ll both have Device.swift. Xcode will see this as a merge conflict, since we’ve both changed the same line. If you just let them both be there, then in your Xcode you’ll probably end up seeing Device.swift twice and it won’t compile.
It would also be more of a problem if I added Device.swift in /Models/Devices while he has it added in /Modell/Gadgets.
Solution: Remove all references to: 5C5809E72257D81500D4CBB2 /* Device.swift or the other. I’m not 100% sure how to decide which one you should remove so I got a copy of my Device.swift before and then start deleting.
And also if files are in two different directories then you’d have to manually delete one of them. Whichever you prefer