iPhone development: how to rename a project in Xcode 3.1
Programming for a new system or platform always makes you start from existing code snippets or even sample projects for you to experiment with.
As you put more and more time into it, you often end up with a project that no longer has anything to do with the original sample. And you probably want to rename it after your final app. So here we go: here is a short process to do that with Xcode 3.1 projects — though it surely works with other versions as well.
All the steps:
- Quit Xcode.
- Rename the old folder to the new name — in this example, say oldproject is to be renamed to newproject; do that straight from the Finder.
- Still in the Finder, go to the newproject folder and rename the files oldproject.xcodeproj and oldproject_Prefix.pch to newproject.xcodeproj and newproject_Prefix.pch respectively.
- Delete the build folder.
- Launch Xcode and open newproject.xcodeproj.
- Open the Project | Edit Project Settings window and click on the Build tab.
- Find the Product Name setting in the list — it appears in bold — and edit its value to newproject (note that it might originally be empty, though).
- Open TextMate and load the file project.pbxproj from inside newproject.xcodeproj, which is actually a package folder.
- Search for the string “oldproject”. Please do that manually; don’t use the Replace All option in TextMate.
- Every time you find oldproject, just replace it with newproject. There is an exception, though: it is not necessary to change the delegate class names such as oldprojectAppDelegate here. If you want to do so, you can refactor them directly from within Xcode itself.
- Save this file and switch back to Xcode.
- Xcode will ask to reload the project file; just click Yes.
- Clean all targets, then Build and Go.
- Everything works with no hassle.
- Last optional step: use Xcode to rename all delegate files — don’t forget to update them in the related code and classes.