Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Here is how to rename a project effectively in XCode4 (INCLUDING THE FILES FOLDER):

  1. Close all open projects completely in XCode to prevent any issues
  2. Copy the Project in question to a new Folder (IMPORTANT: KEEP A BACKUP OF YOUR OLD PROJECT)
  3. Open the Project
  4. Rename the Project itself in XCode4 (double click on the project name), change the name and follow the steps (yes to everything)
  5. Go to product, manage schemes and rename the scheme (double click on the scheme name)
  6. Close your project (make sure is completely closed otherwise the next steps will not work)
  7. In Finder go to the Project folder and right click on the .xcodeproj file, then select the option "Show Package Contents"
  8. Then right click on the .pbxproj file and open it with TextEdit
  9. Replace all occurrences of the Folder Name where the projects used to live (The old project name for the new project name)
  10. Save the file
  11. Open the Project again and Build it!

First of - dont rename an Xcode project!!!

If you have to, the beneath could be it - I never got it to work, ended up creating a new project and started all over copying in the existing files. Xcode is so ahh.... It has so many non productive things, like also try renaming a file from "Name" to "name". Well, well have fun.

I found the answer or how to work around this: Open the pbxproj file by right clicking "Show Package Content" and in there you edit a project.pbxproj file - you have to rename a reference called path and some other stuff - just search for the folder name added "/".

That is it. Hope it helps some one.