Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining new XCode template tags on a per-project basis

It's well known that you can define the values for tags that are used in new file templates, as described at http://cocoadev.com/index.pl?ProjectBuilderTips.

So a typical template looks like this:

/*
 *  main.m
 *  «PROJECTNAME»
 *
 *  Created by «FULLUSERNAME» on «DATE».
 *  Copyright (c) «YEAR» «ORGANIZATIONNAME». All rights reserved.
 *
 */

Now, I know how to define new templates and have done so. However, I want my new template to use my own new tag in it like this:

/*
 *  «ATTRIBUTIONLINE»
 */

... and I want that tag to be definable on a per XCode project basis. Is this possible? I've searched around and can only find the usual stuff about running something on the command line that defines a well-known tag for all projects.

like image 438
occulus Avatar asked Mar 10 '11 14:03

occulus


2 Answers

With xCode4, I find that the project templates have been substantially changed. They seem to be far more editable.

Attached is a sample. Other people have found these templates in ~/Library/Developer/Xcode/Templates/File Templates

I found them here: /Developer/Library/Xcode/Templates/

new template example

like image 189
ICL1901 Avatar answered Sep 21 '22 09:09

ICL1901


Your question is a bit ambiguous. Do you want some of your projects to have a tag defined while others not to or do you want all your projects to include same tag with different values on a per project basis?

I can't be categorical about this, but in latter case "tag to be definable on a per XCode project basis" just begs for different project creation dialog where one would be able to enter a value for custom tag. The former problem would be solved with different project templates (where few project templates hold the tag in question, while others not).

For now, only solution I can think of is to have some kind of command line utility that would "preprocess" the template and then would generate project based on processed project template. Something like rails skeleton templates where you can define which gems to include, then pass that template to rails command which in turn generates the app skeleton with preincluded gems.

Also if you require that big level of customizability - how about moving that tag to separate file templates and then adding/creating those files once the project has been created?

like image 34
Eimantas Avatar answered Sep 20 '22 09:09

Eimantas