20.3. Run Script Build PhaseYou can add arbitrary script actions to a build by adding a Run Script build phase. Select Project New Build Phase New Shell Script Build Phase, and you will be presented with an editor into which you can type commands in the scripting language of your choice (Figure 20.4). Figure 20.4. The Run Script build phase window. You can specify any language you could use in an executable script file. By adding files to the input and output files lists, you can have the Xcode build system run the script only when its products are out-of-date.A Run Script phase can have specific files as inputs and outputs. If these files are present, they will be taken into account by Xcode's build system; if all the outputs are newer than all the inputs, the phase is skipped. If outputs are unspecified, the phase is always executed. The sequence in which a Run Script phase is executed is determined by the availability of its inputs and the need for its outputs. When a Run Script build phase is executed, the script is copied to a temporary directory, and a series of setenv commands copy build variables into the environment. The script is then run, with your permissions, with the project directory current, with the input files passed in as parameters. There are two caveats about build variables and Run Script phases. First, you can't change them: They are passed to your script by doing a setenv for each variable before the script is invoked. When the script finishes, those environment variables, along with any changes you might have made to them, go out of scope. Second, you don't get all the build variables. Apple's documentation suggests that variables that set options specific to a single tool, such as the variables that begin with GCC_, are not exported to the Run Script environment. At present, such variables are exported, if they have been changed from their default values by the current build configuration. So if you have a script that sets up for code-coverage tests when the code-coverage flag (GCC_GENERATE_TEST_COVERAGE_FILES) is set, you will have to test whether that symbol is present in the environmentand know what its absence meansbefore using its value. A cautious user might take Apple's documentation to mean that the visibility of GCC_ and similar variables is not guaranteed in future releases. |
Wednesday, October 21, 2009
Section 20.3. Run Script Build Phase
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment