How to create Xcode project templates

To make your own Xcode Project Template for iPhone development follow these steps:

To make your own Xcode Project Template for iPhone development follow these steps:

1. Open a new finder window and navigate to ~/Library/Application Support/Developer/Shared/Xcode/ (note the ~)

2. Create a new directory in here called Project Templates/

3. Go into the newly created Project Templates/ directory and create a directory for the group your templates will appear in within the new project dialog in Xcode. In this example we will use MyApplication.

4. Open a new finder window and navigate to /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application

5. Copy one of the project templates (the one that best meets your needs) from here to the MyApplication directory we just created.

6. Rename the copied project template directory to the name you want your template to be called.

7. Go into this directory and you’ll find an Xcode project called ___PROJECTNAME___.xcodeproj – Open this project like any normal project and edit it to how you want your newly created projects made from this template to be. You can use ___PROJECTNAME___ in files and directory names and in code and it will be replaced with the project name. ___PROJECTNAMEASIDENTIFIER___ can be used for code where you don’t want spaces or other characters.

8. After setting up your project template how you like, make sure it builds and then go and delete the build directory from the template directory because you don’t want it to create that in new projects. Inside the ___PROJECTNAME___.xcodeproj directory you should also delete the username.* files (where username is your username), these contain things like window state and open files information from the last time you edited the project. If you ever edit your template later on, you’ll need to delete these files again.

9. Finally, change the description of your template in the ___PROJECTNAME___.xcodeproj/TemplateInfo.plist file and optionally change the icons file ___PROJECTNAME___.xcodeproj/TemplateIcon.icns. Search the web for how to edit .icns files, that’s not covered here.

You can even add your project template to SVN and Xcode won’t copy the .svn directories when it creates a new project. This can make it easy to merge useful changes from projects back into your template.

Leave a Reply

Your email address will not be published. Required fields are marked *