开发者

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

开发者 https://www.devze.com 2023-03-05 03:21 出处:网络
I would like to start using my own templates for iOS applications. I don\'t want any significant changes, but simpler things like

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?

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

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 wi开发者_开发问答th no luck. Thanks!


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消