Bob McCune

I intend to live forever. So far, so good.

Bob McCune random header image

XCode Tip #1: Change __MyCompanyName__

March 21st, 2008 · 5 Comments · Cocoa, XCode

If you’re a new XCode user you’ve probably noticed the default header comments in your .h and .m files reference this phantom entity called, __MyCompanyName__. As you most likely don’t work for __MyCompanyName__, let’s change it to something more appropriate.

This value is stored in the PBXCustomTemplateMacroDefinitions dictionary in the com.apple.Xcode domain. You could edit the .plist file directly, but it’s usually easier just to do this through the Terminal.

Begin by opening a new Terminal window. If you want to query for the current value you can enter in the following command at the prompt:

defaults read com.apple.XCode PBXCustomTemplateMacroDefinitions

Your output should look something like:

{
ORGANIZATIONNAME = "__MyCompanyName__";
}

Let’s set this to some more fitting by entering the following at the terminal prompt (all one line):

defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions -dict ORGANIZATIONNAME "Your_Name_Here

For a quick sanity check you may want to execute the defaults read command again just to verify that the value was set. You’ll likely need to restart XCode before these changes get picked up in the IDE.

Now, get back to coding!

Tags:

5 responses so far ↓

  • 1 Brian Marick // Apr 10, 2008 at 12:00 pm

    When I try this, it doesn’t work:

    2106 $ defaults read com.apple.XCode PBXCustomTemplateMacroDefinitions

    2008-04-10 12:51:58.592 defaults[32452:10b]
    The domain/default pair of (com.apple.XCode, PBXCustomTemplateMacroDefinitions) does not exist

    In fact, if I do a “defaults read com.apple.Xcode”, there’s no __MyCompany__ in the output, nor is there anything matching either “Template” or “Custom”. This is XCode 3.0, straight off the leopard disk (I think).

    Whassup?

  • 2 Bob McCune // Apr 10, 2008 at 12:16 pm

    Hey Brian. It sounds like you got the problem worked out. Here is a link to the XCode User Defaults reference that lists all of the keys/values that can be set.

    http://developer.apple.com/documentation/DeveloperTools/Reference/XcodeUserDefaultRef/Introduction/chapter_001_section_1.html

  • 3 hpmueller // May 21, 2008 at 10:49 am

    I agree with Brian,

    the keyword ‘PBXCustomTemplateMacroDefinitions’ does not exist, though it is mentioned in the reference!

    hpm

  • 4 jwnestor // May 31, 2008 at 10:11 pm

    You can change __MyCompany__ on a project by project basis is the XCode window under “Targets”–>”Copy Bundle Resources”

    As mentioned above the macro is described in the documentation (several places) but I cannot find it in XCode.

    jn

  • 5 jwnestor // Jun 27, 2008 at 3:24 pm

    The point was not to replace PBXCustomTemplateMacroDefinitions - rather to enter the definition for the first time. I feel so stupid.

    jn

Leave a Comment