Re: Changing Folder Name in Xcode
On Aug 8, 2017, at 03:50 , Gerriet M. Denkmann <g@...> wrote:
I wouldn’t edit the .pbxproj file. Under the assumption that your project has the files organized under yellow group “folder” icons (in the navigator pane, as opposed to blue “folder reference” icons), you can go ahead and rename the folder to its new name. (For Xcode 8, you should close the project before doing this, because this version has a bug where it doesn’t update the visuals of the navigator pane properly when a file appears or disappears. Re-open the project after the rename.)
When you get back to Xcode, all your source files will have turned red (in the navigator pane). Make sure the File tab of the utilities pane is shown. Select the top-level yellow group icon, then click on the tiny gray folder-like button under its name in the Files tab. You’ll get a standard open dialog, which you can use to choose a new (real) folder to associate with the group icon. Simply choose the newly-renamed folder. Then close and re-open the project, again because of the cosmetic bug mentioned above.
If all of your source file groups are relative to this base folder, all your files should now be black in the navigator. But, if any of the subgroups had other kinds of paths, you will need to repeat the previous step for each one that contains red files, choosing the relevant folder each time.
There’s one final step. There are some files specified by path in settings. Typically this includes the info.plist and the prefix header, if any. You will need to fix those relative paths manually in settings.
HOWEVER, if your project is under git source control, doing all this will likely bork your repository pretty well. AFAIK, Xcode 8 isn’t smart enough to change the relative paths inside the repository. In this case, you should probably find some other piece of software to update the names in the repository *first*, then re-open the project in Xcode and fix the groups’ paths.
ALTERNATIVELY, if you’re prepared to open your project in Xcode 9, it can handle this situation correctly. Before renaming anything, select the top level yellow group icon that contains your source code files. (This should be the one that has your bad old name.) In the navigator pane, select that group and press Enter to edit the name. When you change the name and press Enter, Xcode will rename the folder, and update all of the git information that depends on it. As before, if you have sub-groups that aren’t relative to this group, you’ll have to handle them in a separate step, and you’ll have to change a couple of build settings manually.