Cocoa Templates

When you start a new project and make new source files Xcode starts with template files. You might not like those templates and want to use your own. Here’s how to do it.

Changing file templates

  1. Start by seraching for a folder called “File Templates” on your hard disk. There should be one folder in
    Macintosh HD/Developer/Library/Xcode/File Templates
    (or something similar).

  2. Inside File Templates folder identify Cocoa Class/Objective-C class folder. Make a copy of this folder and put it somewhere save, for instance in your home directory. Now you can make changes to the files in the original folders and be sure to have a back up in case you screw up.

  3. Inside Cocoa Class/Objective-C class folder, you should filnd the four folders
    Objective-C class.pbfiletemplate/
    Objective-C NSDocument subclass.pbfiletemplate/
    Objective-C NSView subclass.pbfiletemplate/
    Objective-C NSWindowController subclass.pbfiletemplate/

  4. Make the changes of class.h and class.m in old the four folders.

  5. Start a new project and make new files. Make sure that your changes work.
    Changing project templates

  6. Start by seraching for a folder called “Project Templates” on your hard disk. There should be one folder in
    Macintosh HD/Developer/Library/Xcode/Project Templates
    (or something similar).

  7. Inside Project Templates folder identify Application/Cocoa Application folder. Make a copy of this folder and put it somewhere save, for instance in your home directory. Now you can make changes to the files in the original folders and be sure to have a back up in case you screw up.

  8. Inside Application/Cocoa Application folder, you should filnd the six folders
    Cocoa Application/
    Cocoa Document-based Application/
    Core Data Application/
    Core Data Application with Spotlight Importer/
    Core Data Document-based Application/
    Core Data Document-based Application with Spotlight Importer/

  9. Make the changes.

  10. Start a new project and make sure it works.