Thursday, February 16, 2006

Command line compilation in XCode


I was browsing through the XCode 2.1 help for compiling multiple targets in one shot when I fell upon xcodebuild. Its a command-line utility for compiling xcode projects. It can be considered like a Makefile for the XCode environment. You should be knowing there are two types of default configurations present in XCode; the Debug mode and the Release mode. To compile all the targets in a project for a specific configuration, go to the project directory which contains the .xcodeproj and give the following command at the command prompt


xcodebuild -alltargets -configuration Release
.

You can replace the "Release" with "Debug". If none is given, xcodebuild takes the default configuration from the XCode environment. If you need to compile to a specific target, just add "-target " to the above command.
You can also clean a particular configuration as below

xcodebuild -alltargets clean -configuration Release