Creating a Scripting Build Phase
With a custom build phase, you can specify a shell script that's executed on specified files in your target. You can copy release notes to the user's disk or compile files with a compiler that wasn't included with Project Builder. Note that you need to know how to use a shell language such as the Bourne shell or C shell.
Custom build phases replace the makefile preamble and postamble files used in previous versions of Project Builder. Project Builder does not let you edit a target's makefile.
To create a custom build phase:
- Click the Targets tab, select the target's name, click the Files tab, and choose Project > New Shell Script Build Phase.
- Enter the pathname for the script's shell, and then enter the script. The script field expands as you type.
- If you want to run the script only when installing the target's product, select "Run only when installing."
Otherwise, the script runs whenever the target is built.
To delete a custom build phase:
- Select the custom build phase, and choose Edit > Delete.
Here are some tips on how to write shell scripts for custom build phases:
- If you're copying code from a makefile, you must edit the code because shell scripts use different syntax and variables.
- The script is executed with the permissions for the logged-in user. For example, if the shell script needs root access, you must log in as root before running Project Builder.
The shell script can use any variable defined in the target's Build Settings. To add a new variable:
- Click the Build Settings tab.
- In the Build Flags section, find an empty line, and enter the variable's name and value.
Related Topics
Build Variables