What environment variables can I use in custom behavior scripts in Xcode 4?
Asked Answered
I

2

6

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.

enter image description here

What variables or arguments are passed to the script that it can make use of?

Irmgardirmina answered 4/11, 2011 at 1:59 Comment(0)
C
13

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
Chimpanzee answered 10/9, 2012 at 11:51 Comment(0)
I
7

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.
Irmgardirmina answered 4/11, 2011 at 2:13 Comment(2)
PWD is another good one - the path where workspace/project is locatedHookup
I also see IDEAlertMessage=Build SucceededRigdon

© 2022 - 2024 — McMap. All rights reserved.