Custom Project Builder Templates

Wednesday, September 24th, 2003 @ 7:28 pm | Programming

Chris Hanson:

The standard response is to change one of the hidden user defaults for Project Builder. But did you know you can easily customize the file and project templates used by Project Builder?

Chris goes on to discuss creating file templates for his open source work.

I was looking at file templates last week and I think it’s cool that creating a new template is so simple. However, I’ve this far been thwarted in my attempts to create a template for Objective-C categories. It just doesn’t seem like there’s any way to split the file name into the class name and extension name.

5 Responses to “Custom Project Builder Templates”

  1. Michael Tsai Says:

    Sounds like a job for a BBEdit glossary item. 🙂

  2. Eric Blair Says:

    How so? When I write categories, my files are usually named ObjCClass-ExtName.(c|h). I think the BBEdit Glossary would have the same problem as the Project Builder templates — the glossary can’t parse the file name to separate the class and extension names.

    Of course, you could create a glossary entry that created a took text in the format of “ObjCClass (ExtName)” and populate the file from that, but then you’d need two variations (.h and .m files) and you’d have to add the file to your project by hand.

    I just don’t see a way to automate the process as nicely as can be done for Objective-C classes.

    Maybe I should just create a template that leaves space for me to enter the class and extension names by hand…

  3. Michael Tsai Says:

    I was thinking that the glossary entry could use AppleScript to do the parsing. I think you’re right about adding the files to the project, though.

  4. Martin Parretti Says:

    In PB try using the macro

    FILEBASENAMEASIDENTIFIER

    which uses the filename minus extension, and ensures that it is a legal C identifier.

  5. Eric Blair Says:

    But if the file name is NSSString-EBExtensions.h, that doesn’t help me separate the “NSString” and “EBExtensions” strings.