Q:

Configure Xcode Source Trees from Command Line?

We have a project that uses Xcode "Source Trees". 
It's important for us to allow people to move these around to use different branches/etc. 
However, for a "stock" setup, we can easily determine what the path should be from a script. 
I'd like to build a script that does a checkout and setup of a new computer because I'm getting tired of walking through the tedious process of setting up machines manually. 
Does anyone know how I can create "Source Trees" in Xcode from a script (simple bash script would be preferred, but I'll use AppleScript if I have to). 

A:

the plist in question is com.apple.dt.Xcode
so you can say:
defaults read com.apple.dt.Xcode

and it will parse and print Xcode's preferences.
the key in question is IDEApplicationwideBuildSettings.
If you have a few defined, you may see something like:
IDEApplicationwideBuildSettings =     {
    "MON_SOURCE_ROOT" = "/Volumes/Dir/Dir/Dir/";
    "MON_THIRD_PARTY_SOURCE_ROOT" = "/Volumes/Dir/Dir/ThirdParty/";
};

now, you can use the write option of defaults to set or remove the values using the command line.
defaults write com.apple.dt.Xcode IDEApplicationwideBuildSettings THE_ARRAY_OF_KEY_VALUE_PAIRS

Where THE_ARRAY_OF_KEY_VALUE_PAIRS is the value to set it to.
You may also need to update IDESourceTreeDisplayNames to create an alias:
IDESourceTreeDisplayNames =     {
    "MON_SOURCE_ROOT" = "MON_SOURCE_ROOT";
    "MON_THIRD_PARTY_SOURCE_ROOT" = "MON_THIRD_PARTY_SOURCE_ROOT";
};

Work on a copy until you figure out the exact command.

