4

Using Xcode 4.5.2

I occasionally want to rename a project all the way through the project without leaving obvious folder name atavisms from previous versions in the project 's file system.

The usual instructions for renaming an Xcode project do not accomplish this. I have read them and done them many times. They only go so far. They leave the main directory (at the same level as the .xcode.proj file) with the ORIGINAL project name. Call me persnickety but I don't like that. So I endeavor to change it as follows.

I begin with the usual instructions, then attempt to rename the remaining original folder name both in Xcode and in Finder. It ends badly. Here are the steps I follow. It should be reproducible.

We will attempt to change a project named "JoeSchmoe" to "JoeSchmoe_1".

Do the Usual Project Rename Procedure

  1. Create a new Xcode Utility project, named: "JoeSchmoe". Use Storyboards and ARC.
  2. Build, run, and test functionality to verify that everything is OK. It is. Stop.
  3. Hit cmd-shift-J
  4. Open the Utilities panel on the right
  5. Under Identity, change project name to "JoeSchmoe_1". Xcode will ask you, "Rename content project items?" Click "Rename"
  6. Build. It should succeed. And it does.

The Problem

  1. In the Project Navigator, notice that the main folder in the project is still named "JoeSchmoe"!
  2. Change the name of that folder to JoeSchmoe_1
  3. Build. It should succeed. And it does. We're done, right? Well let's look at the project's file system.

Quit Xcode

  1. In Finder, open the folder containing the newly renamed and working "JoeSchmoe_1.xcode.proj" (Its containing folder is still named "JoeSchmoe". That's ok for now. We could change it to anything without affecting Xcode, so long as it contains the .xcode.proj file and associated files and directories. We leave it alone.)

  2. In that directory (at the same level as the JoeSchmoe_1.xcode.proj file), notice that the main project folder is also still named "JoeSchmoe" !!

  3. Change the name of this "JoeSchmoe" folder to "JoeSchmoe_1". (We expect this to break the project because we know Xcode will still be looking for the "JoeSchmoe" folder, since it didn't change it for us.)

Start Xcode

  1. Build. It fails, as expected.
  2. Notice that all the filenames in the Project Navigator are now red colored, meaning files not found. (We expected this. Now we want to fix it.)

  3. In the Project Navigator, select the project (top icon), then Target -> Build Settings -> Packaging -> Info.plist File.

  4. Notice the file pathname in the Info.plist File settings row is named: JoeSchmoe/JoeSchmoe_1-Info.plist !! The directory still has the old project name. But in the file system we just changed it. So let's make this the same as what's in the filesystem.

  5. Change its name to JoeSchmoe_1/JoeSchmoe_1-Info.plist

  6. Re-Verify that the directoryname/filenames are identical in the file system and what you have in your Xcode Packaging -> Info.plist setting.

  7. If they are, the project should build. Right?

  8. It Fails. And all of the project files are in red (meaning not found).

  9. Try cleaning the project (Product menu -> Clean),

Quit Xcode, Restart and Build.

  1. It Fails, as before.

At this point I don't have a theory as to why it fails, other than to assume that there is an Xcode setting that needs to be changed somewhere that I haven't yet discovered. Looked all around for it. I'm stumped.

What am I missing?

Han
  • 173
  • 1
  • 9

3 Answers3

1

Since they got rid of the feature that was in Xcode 3 to easily change your project name, it's been a pain in the butt to do manually. I found a great app in the mac strore Project Duplicator for Xcode 4 that copies your project and lets you name it whatever you want. I've been using it for a while now and have never had an issue with it, and it was only $1 when I purchased it.

GW

GW.Rodriguez
  • 1,181
  • 8
  • 18
  • Thanks for your reply. But an Oct 11, 2012 review of "Project Duplicator" says it doesn't work with Xcode 4.5. Is there *any* way to do it manually, _at all_? – Han Jan 14 '13 at 16:27
  • Oh really? hummm, well I just used it and I'm running Xcode 4.5.2. Sorry, I'm not sure how to do it manually. – GW.Rodriguez Jan 14 '13 at 20:24
  • By golly, you're right! It just worked perfectly on the same test I outlined above. THANK YOU!!! – Han Jan 15 '13 at 02:58
  • Hmm, I find that it works perfectly on a newly created project, as above, but on older working projects it doesn't change the Main Folder's project subfolder, at the same level as the project file. Probably because I fiddled with something manually, previously, in it. Just a guess. So I'm still interested in a manual process, if anyone knows how to do it. Meanwhile, "Project Duplicator" is useful. – Han Jan 15 '13 at 16:29
1

The last thing I had to change when renaming a project, including the finder folders, is the setting under "Build Settings->Prefix Header". It was still pointing to a finder folder that no longer existed and the compiler would throw on a file not found error.

Once I changed this to my new inner project folder, it all worked fine and I've been able to build the project as expected.

cwgso
  • 401
  • 3
  • 9
0

See this answer for fixing the problem manually

Renaming xcode 4 project and the actual folder

Community
  • 1
  • 1
Josh Liptzin
  • 746
  • 5
  • 12