Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 338
Brant Bobby Avatar asked Dec 02 '22 01:12

Brant Bobby


2 Answers

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
like image 195
user1660043 Avatar answered Dec 04 '22 05:12

user1660043


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.
like image 45
Brant Bobby Avatar answered Dec 04 '22 05:12

Brant Bobby