Thursday, July 22, 2010

how to duplicate a project in Xcode

 These steps seem to work for me in Xcode 3.2:

1. In the Groups & Files pane, control-click on the project name (e.g. "ExampleProj") and choose the "Reveal in Finder" option.

2. Make a copy of that folder (e.g. "ExampleProj copy") and rename it to the name you desire for your duplicate project (e.g. "ExampleProjDuplicate").

3. Go inside the new folder and rename the .pch and .xcodeproj entries (e.g. rename "ExampleProj_Prefix.pch" to "ExampleProjDuplicate_Prefix.pch" and "ExampleProj.xcodeproj" to "ExampleProjDuplicate.xcodeproj".

4. The .xcodeproj is actually a folder, you can see its content in Finder by control-click it and choose "Show Package Content". You should see a project.pbxproj file in there.

5. Open the project.pbxproj file in a text editor and replace all old references to the .pch file to the new one that you renamed at step 3 (e.g. replace all "ExampleProj_Prefix.pch" to "ExampleProjDuplicate_Prefix.pch")

6. Load the new project file (e.g. "ExampleProjDuplicate") in XCode and choose the "Build"->"Clean all Targets". 

7. Done.


Sly said...

Excellent ! Thanks for sharing

Anonymous said...

Worked perfectly on xcode 3.2.6. Lots of people advising to duplicate the target not the project, but I am using PhoneGap so this is more suitable.
Thank you!

rdf said...

I just wrote up a similar post for xCode 4.3.3

Anonymous said...

No .pch in xcode 5?

Anonymous said...

I am getting this error when I run the build

Command /Applications/ failed with exit code 1