Xcode 4 lets you create custom behaviors that are performed from the Xcode > Behaviors menu, or are triggered by a keyboard shortcut. One of the actions that can be taken is the execution of an application or shell script.
What variables or arguments are passed to the script that it can make use of?
The environment may be context specific (depending on what is selected in Xcode), but this will show the environment variables available in a given context:
Make a script file containing
#!/bin/sh
env | sort > ~/Xcode_behaviors.out
Don't forget to make the script executable.
Then create a new Xcode Behavior that calls the script file. The output file contains the environment variables that are available. See them with:
cat ~/Xcode_behaviors.out