HOWTO set the default target in Xcode

Your Xcode project has one or more targets. Each target builds something—a command-line tool, a framework or an application.

The Target popup menu lets you determine the active target. The active target gets built when you click “Build” or “Build & Go.”

But what about the default target? What is it, and why do you care? Well, if you build from the command line—using xcodebuild—the default target (and only the default target) gets built.

So how do you set it? I looked around in the help, and it wasn’t obvious. Turns out the answer is in the xcodebuild man page:

By default, xcodebuild builds the first target listed in your project, with the default build configuration. The order of the targets is a property of the project and is the same for all users of the project. The active target and active build configuration properties are set for each user of the project and can vary from user to user.

The default target is the first target listed. In this example, the default target and active target are the same — The “Palm Pre UI” Cocoa application:

Suppose we wanted to make the “Shell tool” command-line tool the default target. Simply drag it so it becomes the first item on the list:

Now we’re done. The active target is still the “Palm Pre UI” Cocoa application, but the default target is the “Shell tool” command-line tool:

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *