Important: The information in this document is obsolete and should not be used for new development.
In addition to building your product from within the Xcode
application, you can use xcodebuild to
build a target from the command line. Building from the command
line gives you additional flexibility compared to building from
within the Xcode application that may be useful in certain circumstances.
For example, using the xcodebuild tool,
you can create a script that automatically builds your product at
a specific time or build targets from multiple projects at the same
time.
Note: If
you need root privileges to install a product in its deployment
location, you must build the product with the xcodebuild tool, because
Xcode cannot grant you these privileges.
The xcodebuild tool
reads your .xcode project
bundle and uses the target information it finds there to build a
product. However, there are differences between building within Xcode and
building from the command line:
When you
build within Xcode, it uses the active target and build style. When
you build from the command line, xcodebuild uses
the first target in the project’s target list and no build style,
unless you specify a target or build style with a command-line option.
If you run xcodebuild as
the root user, the preferences you set in the Xcode Preferences window
are not used. Preferences are stored per user, and there are no
preferences stored for the root user (unless you logged in as root
and used Xcode at some point).
To build a target using xcodebuild,
use the cd command to
change to your project’s directory and enter the xcodebuild command
with any command-line options you wish to specify. The project’s
directory contains your project’s .xcode bundle.
For example, if your project is in ~me/Projects/MyProj,
enter cd ~me/Projects/MyProj.
You can use xcodebuild to
build a product suited for deployment and install the product in its
final destination path. To do that, use the xcodebuild tool
with the install option,
which places the product in the distribution root specified by the
DSTROOT, Installation Path (INSTALL_PATH), and Deployment Location
(DEPLOYMENT_LOCATION) build settings. For example, to install a
framework in /Library/Frameworks,
configure the build settings as shown in Table 27-1.
Build setting name |
Value |
|---|---|
DSTROOT |
|
INSTALL_PATH |
|
DEPLOYMENT_LOCATION |
|
The DSTROOT build setting can be set only in the xcodebuild command-line
specification:
% sudo xcodebuild install -buildstyle Deployment DSTROOT=/ INSTALL_PATH=/Library/Frameworks DEPLOYMENT_LOCATION=YES |
See the xcodebuild man
page for information on the available options and command usage. For
details on framework placement, see Mac OS X Frameworks.
Last updated: 2006-11-07