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
From my own experimentation, I found that Xcode sets the following environment variables before running a custom script:
XcodeDeveloperDirectory
-- the root path to your developer tools installation, i.e. /Developer
XcodeDeveloperApplicationsDirectory
-- path to developer applications, i.e. /Developer/Applications
XcodeDeveloperPlatformsLibrary
-- path to the developer platforms, i.e. /Developer/Platforms
XcodeProject
-- name of the currently open project, i.e. MyProject.xcodeproj. This variable is not set if you have a workspace open.XcodeWorkspace
-- name of the currently open workspace, i.e. MyWorkspace.xcworkspace.XcodeWorkspacePath
-- path to the currently open workspace, i.e. /Users/You/Code/My iPhone App.xcworkspace. If you have a single project open, this will be something like /Path/To/OpenProject.xcodeproj/project.xcworkspace instead.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With