There are lots of howtos, but none of them really did the job for me. So here’s how I do it (I assume you want to reneme OldProject to NewProject):
- Rename the OldProject.xcodeproject, and the folder it is in.
- Inspect the contents of your OldProject.xcodeproject (”Show Package Contents” in finder), there should be a file project.pbxproj. Edit that in your text editor. I used Emacs, but I guess you should be fine with any decent editor that repects the character encoding. Close the project before editing, or make sure your editor auto-loads changed files.
- In project.pbxproj, replace some occurrences of your old project name with your new one. Don’t replace anything in comments, and no filename replacements (like OldProject.m). Some important locations are OldProject.app (there should be one occurrence where it’s not in a comment) and some constructs with “path”, “PBXProject”, “PBXNativeTarget”, “PRODUCT_NAME”, “productName”, “name”.
- Test loading, building and running the project. It should work as before and feature your new project name in the relevant locations (e.g. it should be NewProject.app now). If xcode complains about corruption it might be because you ignored character encoding or didn’t hit all locations of OldProject.
- Optional: As soon as your project is working as before, you can rename all your source files that have OldProject in their name and all references (like #import and the like). This might take some time in a large project.
- Optional: If you renamed your source files, your xibs will probably be wrong too. Correct all references to OldProject until your app is running smoothly again. Also check your code if you’re using “initWithNibName”.
- Done! You should probably test your app thoroughly, especially if you’re lazy-loading views and the like. They could still be erroneous references to OldProject classes.
I hope that helps. I know it sounds like a lot but it should be feasible in about 5 minutes, without the optional source file renaming which could take quite a while in a large project. Again, backup!
Tags: iphone, xcode