How to evict __MyCompanyName__ from their office building

2006-03-28 17:42:00 -08:00

UPDATE 2008-07-15: You no longer need to do this as of Xcode 3.1. Make sure you fill out your Address Book. (If you don’t want to use the company name on your Address Book “Me” card, then you do need to follow these instructions.) Thanks to BJ Homer for pointing this out in his comment.

Xcode comes with a number of document templates. You see the list of them when you choose File→New Document in Xcode. The templates are actually stored at /Library/Application Support/Apple/Developer Tools/File Templates. Most files contain a header comment that looks like this:

/*
 *  «FILENAME»
 *  «PROJECTNAME»
 *
 *  Created by «FULLUSERNAME» on «DATE».
 *  Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved.
 *
 */

The problem is ORGANIZATIONNAME. This gets replaced with “__MyCompanyName__”, and there is no obvious way to change this other than by changing it every time (or by editing the templates, a solution that gets clobbered when you upgrade Xcode).

I was reading Step into Xcode, and found that on page 53, it gives instructions for defeating __MyCompanyName__. Here’s the important part, from the book:

defaults write com.apple.xcode PBXCustomTemplateMacroDefinitions '{ ORGANIZATIONNAME = "Joan Smith"; }'

This information is also available on this Xcode release notes page. It’s slightly inaccurate (__CompanyName__ rather than __MyCompanyName__) and well-buried, but it documents the same thing as the book.

Presumably, you could override any macro name or add your own using that default. But ORGANIZATIONNAME is the important one.

I debated about posting this here (publicly, rather than only privately to the Adium and Growl developer lists), because I got the info from the book. But I decided that it’s OK because (1) it is also documented by Apple and (2) it’s an example of the good info in this book. So here it is.

UPDATE 2007-04-07: Markus Magnuson sagely points out that you must relaunch Xcode after making this change. This really applies to any application whose prefs you plan on hand-modifying; Xcode is no exception. Thanks for the reminder. ☺

5 Responses to “How to evict __MyCompanyName__ from their office building”

  1. nehemiah Says:

    pritty awsome tip, it should go into cocoadevcentral permanently as the first step as in the xcode tutorial

  2. Markus Magnuson Says:

    Just wanted to add that you’ll have to restart XCode for this to kick in, if it was open when writing to defaults.

  3. BJ Homer Says:

    From the Xcode 3.1 release notes:

    The ORGANIZATIONNAME substitution value in templates is now replaced with the Company Name from the current user’s Address Book card if present, rather than __MyCompanyName__. If the PBXCustomTemplateMacroDefinitions user default has already been set, it will be honored.

  4. Steven Fisher Says:

    I had to follow the instructions here to change the company name. Although Xcode was picking up the value from the address book, it wasn’t smart enough to drop the “Ltd.”, or at least that period, from the value. So I ended up with “Ltd..” in my source files.

    Short version of all this: If you have a suffix like “Ltd.” or “Inc.”, don’t include the period in the defaults write.

  5. Greg Says:

    The path for this seems to have changed. On my machine with XCode 3.0 it’s at:

    /Developer/Library/Xcode/File\ Templates

Leave a Reply

Do not delete the second sentence.


Warning: Undefined array key "ntt_saved_comment_text" in /home/public/blog/wp-content/plugins/negative-turing-test/negative-turing-test.php on line 143