How To Rename An Xcode Project

# Filed on May 16, 2009 by AnthonyDiSante 5 replies

When you’re using Xcode to develop an iPhone app or a Mac app, you might decide that you need to rename your project.  In many cases this would mean not only renaming the actual executable file that gets produced, but also the names of various source code files, project folders, and the contents of various files within the project.

As far as I can tell, Xcode provides no way to do this.  There are a few settings that seem like they might do part of it, but every time I tried to use one of them within Xcode, it just resulted in errors and my project failing to build.  After many hours and much frustration with Xcode, I decided to try it the Unix way, and it worked.  The solution is a straightforward 3-step process:

1. First I closed Xcode, and made a backup of my project folder.  Then I went into my project folder and renamed every file and folder which contained "OldName" so that it now contained "NewName" instead.  This could be scripted pretty easily but my current project is a small one so I spent the ~5 minutes to manually rename the files and folders.

2. In the project folder, I ran the following command in a terminal, to update the contents of the files in the project:

find . -type f -exec sed -i 's/OldName/NewName/g' "{}" \;

3. I opened the now-renamed project in Xcode and clicked Build -> Clean All Targets.

After that, the project (with the new name) built successfully.

Comments:

01. Jan 6, 2010 at 09:49pm by PaulMasson:

Brilliant! Works like a charm with one modification: for Mac OS X Leopard, you must specify an empty extension with the -i switch, or the stream editor will return an "invalid command code" message.

02. Apr 2, 2010 at 12:59am by MikeTheCat:

OK, that sounds nice, but those of us who are new to the Mac/OSX don’t know the command syntax to "specify an empty extension" with the -i switch.  I’ve also seen some reference to need for the -e switch when using -i, but that might not apply here.

Can you show the modified command to include the "empty extension"?

03. Apr 2, 2010 at 02:54am by MikeTheCat:

Other info, such as on forums macosxhints com, suggest that all of these should work in Leopard.

find . -type f -exec sed -i "" ’s/OldName/NewName/g’ "{}" \;

find . -type f -exec sed -i "" -e ’s/OldName/NewName/g’ "{}" \;

find . -type f -exec sed -i -e ’s/OldName/NewName/g’ "{}" \;

find . -type f -exec sed -ie ’s/OldName/NewName/g’ "{}" \;

Can anybody confirm if which of those, if any, will work?

04. Apr 2, 2010 at 07:43am by AnthonyDiSante:

If you run the command "man sed" you’ll see the sed manual, which explains how the -i switch works.  Here’s a quote:

-i extension: Edit files in-place, saving backups with the specified extension.  If a zero-length extension is given, no backup will be saved.

So just plain -i, or -i followed by empty quotes, will probably both work the same; either way should be fine.

05. Apr 2, 2010 at 02:13pm by MikeTheCat:

The post from Jan 6 suggested that the -i by itself doesn’t work in Leopard without the "" to specify the empty extension, but thanks for the additional lead to the full information.  This will help me form the habit of using that tool.

Reply to this message here:

Your name
Email (why?)
Website (if you have one)
Subject
search posts:

home | archives ]

Client Quotes

I just installed the demo of your product and got it up and running in no time.  I searched high and low for a decent login script and thank God I found yours.
– Adrian F.
I spent ages trying to find a way of making my own log in page for my website - if you're thinking of doing that forget it - don't waste your time!  UserBase is a 1st class product at a very reasonable price.  The software works faultlessly and can be adapted to any situation.  The service that I have received from Encodable is terrific!  I am very very impressed.  Nothing was too much trouble and I am most grateful to Anthony DiSante in particular for all his help and patience.
– Paul S.
Worked like a charm... man, this piece of software is a dream and I really appreciate all your customer service help getting this taken care of.
– Kyle M.
I just want to say you guys really stand alone in that you have a quality product and you provide genuine customer service.  It's sad but those qualities are seldom found separately, much less together.  Thanks again for your time and help.
– Alex S.
Also, I wanted to tell you that I was very skeptical about buying this script.  I've spent a lot of time and money over the past 3 months trying to find a solution that works, but I ended up having problems with so many of the scripts I tried that I was almost to the point of giving up.  But then I came across your script, and it actually does what it's supposed to.  An absolute wow.  A very impressive and powerful script indeed!  Many, many thanks!
– Mike E.
I can't thank you enough, I was up against a deadline that required me to get this up and running in 48 hours and you have probably the best customer service I've ever seen.
– Dan T.
Your scripts/software are the greatest, I mean I really love how customizable they are, how intuitive they are, and so on.  Thanks again, I love this stuff!
– Tucker O.
We searched for a long time for an application to password protect directories and allow file uploads.  Userbase & Filechucker are far superior to anything out there.  Simple yet powerful programming, extremely flexible in configuration, and great customer service.  Thanks for a superb product.
– Kat G.
Thank you VERY much for all of your help.  You've really impressed me.  We have support agreements for other software that costs thousands of dollars / year (just for the support), and most of them aren't as helpful as you have been.
– Keith Y.
There are a lot of these scripts out there, but I think they all pale in comparison to yours.
– Peter W.
The software has some great features, is well presented, runs where others are problematic and will make a good impression on our clients.  We look forward to reaping its benefits!
– Alex H.