Its really hard to find a tutorial to do this as most information relates to Xcode 3. Answer below may help some people.
I sourced most of my information for the answer below from the following sites:
Creating A New Project Template To get started create a folder under “Project Templates” to store the template. The folder name shows up as the section name in the Xcode template browser. To make changes to the template we need to edit the TemplateInfo. plist file.
They are located in Xcode. app/Contents/Developer/Library/Xcode/Templates or Xcode. app/Contents/Developer/Platforms/<platform_name>/Developer/Library/Xcode/Templates.
I spent hours searching the web to find information about doing this. Its not actually that hard to set up project templates for Xcode4.5 but its hard to find information on the web that puts it all together! Hopefully the steps below will help you to create your own.
Setting Up
[EDIT] In Xcode 5 the PATH is as follows: ~/Library/Developer/Xcode/Templates/Application/Project Templates. If Templates/Application/Project Templates not exists you should create it too. Credit to seufagner in the comments below for the update although I have not tried this myself. [/EDIT]
Customising
At the moment you have a copy of an existing project template which is not very useful. I'm guessing you have a number of classes that get reused in nearly all your projects? How about we include them into this template?
Open the TemplateInfo.plist file in TextEdit again. First thing we have to do is tell the project template to include the new files so search for a key called "Nodes" that has an array of values. Add the two following lines:
<string>_VARIABLE_classPrefix:identifier_.h</string> <string>_VARIABLE_classPrefix:identifier_.m</string>
For example if your controller was called BaseViewController the lines would look like:
<string>___VARIABLE_classPrefix:identifier___BaseViewController.h</string> <string>___VARIABLE_classPrefix:identifier___BaseViewController.m</string>
Hope this is actually useful to someone :) Any questions comment below and I'l do my best to answer. I did this a few weeks ago so my memory is a little hazy.
You can also learn a lot from inspecting the existing project templates, which you can find in:
/Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/
for Mac and
/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/
for iOS.
There are few sample templates also on GitHub by Reid Main and another one by Acani. There are also AFNetworking templates, created by Mattt Thompson. See all the examples, including ones built by Apple and then you can start creating your own.
A good overview of all of the variables used in the plist file can be found here: https://gist.github.com/shazron/943736
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With