Moving Files in XCode
Couple of times I made silly mistake of creating new files in XCode project not in the place I want them to be in filesystem. Groups and “real” folders still confuse me. When you have such file in your project that is in correct group, but not in correct folder on the disk and you don’t want to remove it’s reference and add the same file again I have two steps solution for you.
First you open Finder (or any other file commander tool) and move the file to the correct location. When you will open XCode you will see that this moved file is red now (this is expected behavior, XCode cannot find this file under old location):
What you have to do is to highlight this file and open File Inspector (menu View -> Utilities -> File Inspector or by keyboard shortcut <command> + <option> + <1>). Just under Location combo box there is specified current location for this file. Hit the little folder icon on the right and choose the new path of the moved file:
And that’s it. The drawback of this solution is that you have to repeat this steps for each file you want to move, but if you have plenty of them, probably it’s better to remove references and add them again.
Hi. WIth Git this method does not work properly. ‘D’ (deleted) mark remains after reassigning a new file.
Instead, copy a file to a new location and add it to a new group. Then, delete old one from Xcode.
Maybe you are right, but ‘D’ mark (or ‘?’ mark – new untracked file in my sample project) will remain because of git version control.
For git it does not matter if you move or copy and then remove the file. In both cases the old file will be marked as deleted and the new one will appear as untracked.
I found out that usually it is good to switch to Version editor after you make changes outside Xcode IDE to refresh git status of the project.