Sunday, 12 April 2009

How to rename an Xcode project

I've recently been working on a iPhone framework which performs Tweetie style navigation - basically supporting a tab bar controller within a navigation controller, as this isn't supported natively by the iPhone SDK. I developed the framework in a seperate project and wanted to use this as a base for a new project I've just started working on. It's fairly simple to take a copy of an existing iPhone Xcode project and rename it for a new project - here are the steps I followed -

In Finder, copy the old project directory to a new location and rename the folder to reflect the new project name.

Move the <oldproj>.xcodeproj file in the project directory to <newproj>.xcodeproj.

Open the new xcodeproj file/project in Xcode.

If using version control on the provious project, turn that off - right click the project, Get Info and set the version control drop down value to "None".

Refactor those classes that carry the <oldproj> name e.g. open the application delegate header file <oldproj>AppDelegate.h, right click the class name <oldproj>AppDelegate and then select refactor. Rename to <newprog>AppDelegate, Preview then Apply. Repeat this for any classes that hold the old name.

In Other Sources, pick the <oldproj>_Prefix.pch file and refactor - rename to <newproj>_Prefix.pch.

Select the <oldproj> build target and rename to <newproj>.

Bring up info for the <newproj> target - Select “All Configurations”, “All Settings” and navigate through the build configuration settings changing these references of <oldproj> to <newproj>Product NameGCC_PREFIX_HEADERBuild and test