Renaming xcode 4 project and the actual folder Renaming xcode 4 project and the actual folder xcode xcode

Renaming xcode 4 project and the actual folder


You can do this from within Xcode without resorting to hand editing the pbxproj file in a text editor!

Here's how:

  1. Rename your source folder in the Finder. This will break the project initially because Xcode doesn't automatically detect when the real folders that the virtual (yellow) project folders point to are changed, so all the files inside that folder will turn red in Xcode. Don't worry about that, we'll fix it in step 3.

  2. In Xcode, click on the (now broken) virtual folder in the left-hand sidebar and rename it to match the name in the Finder (you can actually call it anything you want, or not rename it at all, but that would be insane). That won't fix the red files inside the folder, but that's OK.

  3. In the right-hand sidebar in Xcode, click the icon shown in the screenshot below to bring up a file dialog. Select the folder that you previously renamed. This will re-associate the virtual folder with the real folder on disk, and will automatically fix the links to all the files inside.

  4. In your build settings, search for the old folder name and manually rename any occurrences you find. There will typically be two of them, oldfolder/prefix.pch and oldfolder/info.plist, but there may be others.

All done!

enter image description here

EDIT: this option is still there in Xcode 5, but is helpfully hidden by default. To show it, click the thin "Identity and Type" header in the inspector above the "Text Settings" panel to expand it.


I've done it dozens of times:

  • Rename the Project by clicking then editing the Title in your Xcode Project Navigator.
  • Close Xcode.
  • Rename the source folder.
  • From the Finder, open the .pbxproj file inside project bundle (context menu "Show Package Contents") with any text editor.
  • Search and replace any occurrence of the original folder name with the new folder name.
  • Save the file.
  • Open Xcode project.


Task: Rename "Play" to "Play2" both in Xcode and in Finder

Change this:

enter image description here

To this:

enter image description here

STEPS:

// Before anything, please backup the project in Finder!

  • Rename project in Xcode Project navigator // Click project name then hit enter
  • Rename group in Xcode Project navigator // not affecting folder name in Finder
  • Close Xcode
  • Rename outer folder (left column in image) in Finder

// All above steps are straight-forward and without side effects//// Now comes the tricky part: rename the inner folder (middle column in image) in Finder (the one at the same level with .xcodeproj)

  • Rename the inner folder in Finder while keeping Xcode closed
  • Right click .xcodeproj, select "Show Package Contents"
  • Open .pbxproj file with Mac TextEdit
  • Search and replace all "Play" with "Play2". To guarantee everything goes right, click the arrow on the left end of the search bar and modify the search attribute. Change "Contains" to "Full word", and uncheck "Ignore case"
  • Save .pbxproj file
  • Open Xcode project and Run