I was looking for a way to automatically add the LGPL license to the header of the GLSCollections classes when I stumbled across
this link at CocoaDev explaining how to add custom file templates in older versions of Xcode. It's not quite the same as what's explained on that page anymore, so here's how it's done now.
The templates are no longer in
/Library/Application Support/Apple/Developer Tools/File Templates/ in Xcode 3.1. It is now in
/Developer/Library/Xcode/File Templates/
Under this folder there are several subfolders coinciding with all of the different types of default templates of Cocoa files. In my case, I wanted a standard Objective-C class template that automatically included the LGPL license header.
First, go into the Cocoa subfolder and make a copy of
Objective-C class.pbfiletemplate. In my case I renamed it to
Objective-C LGPL class.pbfiletemplate. The default template for a .m file looks like this:
//
// «FILENAME»
// «PROJECTNAME»
//
// Created by «FULLUSERNAME» on «DATE».
// Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved.
//
«OPTIONALHEADERIMPORTLINE»
@implementation «FILEBASENAMEASIDENTIFIER»
@end
In the new copy, change it to this:
//
// «FILENAME»
// «PROJECTNAME»
//
// Created by «FULLUSERNAME» on «DATE».
// Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
«OPTIONALHEADERIMPORTLINE»
@implementation «FILEBASENAMEASIDENTIFIER»
@end
It's that simple. The only thing I haven't yet tested is whether or not this folder gets wiped out when you install a new version of Xcode so make sure to backup your new templates to a safe place.
I also found some other tags on CocoaDev that can be inserted into the templates for automatic replacement. If you know of any others, let me know
«DATE» Current date (using NSCalendarDate format "%x")
«DIRECTORY» Full path of the file's parent directory
«FILENAME» Full file name, as typed by user
«FILEBASENAME» File name without the extension
«FILEBASENAMEASIDENTIFIER» File name without the extension, mangled to a legal C-style identifier
«FILEEXTENSION» Current file's extension
«FULLUSERNAME» Full name of the logged in user
«PROJECTNAME» Name of the project to which the file was added (blank if none)
«PROJECTNAMEASIDENTIFIER» Name of the project, mangled to a legal C-style identifier
«PROJECTNAMEASXML» Name of the project, as a valid XML string
«TIME» Current time (using NSCalendarDate format "%X")
«USERNAME» Account name ("short name") of the logged in user