Rename xCode project

As of xCode 4, renaming project became much more simple, but still has some tiny considerations to be taken into account. In the simple example below I rename a project called ViewSample to UIView_from_Xib.

First simply rename the project and the targets with the help of xCode just by clicking on the project name in the Navigator panel.

With that, the project can yet build with the new name, but it leaves you with instances of the former project name scattered all around the project.

Rename xCode project source folders

First you probably want to rename source file container group(s), and so the underlying folder(s) on the disk. Renaming the group is straightforward, you just altering the group name in this case. But once you rename the folders beneath, xCode won’t find the sources anymore.

You can easily remap a group’s file system reference in the File System Inspector utility panel on the right. Just remap source folders there.

You can easily remap a group's file system reference in the File System Inspector utility panel on the right.

Click on the tiny folder icon on the right.

This will still leave you with some path inconsistencies, so go to the Build Settings for the application target, and search for the former name, ViewSample this case. You’ll see that the path for Info.plist, and Prefix.pch files are just still referenced in the previous source directory, so rename them manually.

You’ll see that the path for Info.plist, and Prefix.pch files are just still referenced in the previous source directory, so rename them manually.

Same goes for the test target if any, where you have to rename Bundle Loader paths as well. Note that Prefix.pch is referenced from the application source folder.

If you have some class names those were specific for you project name, you can rename them safely using xCode refactor, though, this step is optional anyway. But in the end, renaming a project is optional as a whole.

Rename xCode project schemes

Only thing that can still poke your eyes is the Scheme name on the top left. Simply rename at Product / Schemes / Manage Schemes… manually.

Only thing that can still poke your eyes is the Scheme name on the top left. Simply rename at Product / Schemes / Manage Schemes… manually.

You may want to update comments in source headers, so a Find / Find and Replace in Project… can cure this issue as well.

You may want to update comments in source headers, so a Find / Find and Replace in Project… can cure this issue as well.

So the former project name gone forever, yay.

DISCLAIMER. THE INFORMATION ON THIS BLOG (INCLUDING BUT NOT LIMITED TO ARTICLES, IMAGES, CODE SNIPPETS, SOURCE CODES, EXAMPLE PROJECTS, ETC.) IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE INFORMATION ON THIS BLOG (INCLUDING BUT NOT LIMITED TO ARTICLES, IMAGES, CODE SNIPPETS, SOURCE CODES, EXAMPLE PROJECTS, ETC.).

Become a Patron!
  • nik

    In Xcode 5 renaming your project is very simple. Howeve,r it doesn’t work and there’s remnants of the old name all over the place. This must be the worst piece of programming I’ve ever seen. Why even add all these dependencies in the first place? Why name dozens of files, folders, targets, identifiers after the project? It’s madness.