Defining new XCode template tags on a per-project basis
Asked Answered
C

2

10

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.

Cringle answered 10/3, 2011 at 14:48 Comment(0)
P
3

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

Prom answered 17/3, 2011 at 1:35 Comment(2)
Thanks, but how does this relate to defining a custom tag on a per-project basis?Cringle
occulus - could you put insert your own custom tag in the Definitions?Prom
J
1

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?

Jeramey answered 15/3, 2011 at 20:51 Comment(1)
Thanks for your answer. The key issue is that I want to be able to define new tag, on a per-project basis, that is substituted into any templates that are used. It doesn't really matter if different projects have different templates or not, the key is that at the point of instantiating a template, XCode can pull a custom tag from some definition tied to just that project.Cringle

© 2022 - 2024 — McMap. All rights reserved.