Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a new "templates" category on Xcode 4 and use my own file templates there?

I would like to start using my own templates for iOS applications. I don't want any significant changes, but simpler things like

  • add/remove some boilerplate code
  • add some pragma mark sections
  • hardcode my company's name and some comments for every file
  • change the indentation
  • etc etc etc

The idea is that we will share these templates when we create apps, but at the same time we want to keep the default template files that Xcode 4 already provides. So, in the following screenshot, how can I add a "CompanyName Application" section that contains exactly the same templates (Navigation-based, View-based etc), but with my own changes?

Xcode 4 templates

I found that I can add a folder under /Developer/Library/Xcode/Templates/ or /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/ but I'm a bit confused with what do I need to do exactly. I would really appreciate it if you could help me with that, as I have already messed up my folders twice with no luck. Thanks!

like image 259
phi Avatar asked May 12 '11 09:05

phi


2 Answers

This blog post by borealkiss has detailed instructions. For starters:

If you add your own templates, the place you should use is under the following path:

~/Library/Developer/Xcode/Templates/

The problem is that it is quite hard to create a custom template. For example, to copy and paste the built-in template to your place will not show up the template on Xcode 4 until you manually change its identifier in TemplateInfo.plist.

like image 163
Hagelin Avatar answered May 31 '23 02:05

Hagelin


I just found this article from Bob McCune "Creating Custom Xcode 4 File Templates" that is exactly what I needed, so I put it here for reference.

like image 42
phi Avatar answered May 31 '23 04:05

phi