How to evict __MyCompanyName__ from their office building
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. ☺
April 5th, 2007 at 10:11:57
pritty awsome tip, it should go into cocoadevcentral permanently as the first step as in the xcode tutorial
April 7th, 2007 at 22:05:43
Just wanted to add that you’ll have to restart XCode for this to kick in, if it was open when writing to defaults.
July 15th, 2008 at 09:35:34
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.
February 19th, 2009 at 11:13:17
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.
July 26th, 2009 at 18:30:56
The path for this seems to have changed. On my machine with XCode 3.0 it’s at:
/Developer/Library/Xcode/File\ Templates