< Previous PageNext Page > Hide TOC

Overview of an Xcode Project

To carry out the development process, Xcode relies on certain key components. It uses projects to organize these components. The project is a repository for all of the information needed to build one or more software products. It is also the primary workspace for your software development. This chapter describes the contents of an Xcode project and gives an overview of the information required to develop software with Xcode.

In this section:

Components of an Xcode Project
The Project Directory
The Project Info Window


Components of an Xcode Project

A project contains and organizes everything you need to create one or more software products. In your Xcode project, you:

To develop a product using Xcode, you must understand the key components of your project. Figure 1-1 shows a simplified representation of a project and its essential pieces.


Figure 1-1  The key components of a project

The key components of a project

Source Files

Source files are the files used to build a product. These include source code files, resource files, image files, and others.

A project keeps all of the source files you use for a particular product or suite of related products. A project can also contain files that are not directly used by Xcode to build a product, but contain information that you use during the development process, such as notes, test plans, and more.

In the course of developing a product, you edit source files—using Xcode’s built-in text editor or an external editor—and organize files into a target (described next) to define the build system inputs for creating the product.

A project keeps a reference to each file you add to the project. A project can also contain folder references (if you want to manipulate a group of files as a whole), framework references to access the contents of a framework, or references to other projects. “Files in Projects” describes how Xcode stores these references and discusses the files in a project in more detail.

Targets

When it comes time to actually create, or build, a product, you use a target. A target defines a single product; it organizes the inputs into the build system—the source files and instructions for processing those source files—required to build that product. To create a finished product, build its target. Projects can contain one or more targets, each of which produces one product.

Targets, and the products they create, may be related. If a target requires the output of another target in order to build, the first target is said to depend upon the second. Xcode lets you add target dependencies to express this relationship. Targets describes targets and the instructions they contain in more detail.

For each target in your project, Xcode adds a product reference. This is a file reference to the output generated by the target, such as an application. You can use this product reference to refer to the products in your project the same way you use a file reference to refer to a file; however, the product reference does not actually refer to anything in the file system until you build the product.

Executables

Executables. After you’ve successfully built a product, you need to test it to make sure that it works. When it comes time to run or debug your product, you use an executable environment to tell Xcode how to do so. An executable environment tells Xcode what program to launch when you run or debug from within Xcode and how to launch the program. The executable environment lets you tell Xcode what command-line arguments to pass, what environment variables to set, what debugger to use, and so forth.

If you are building a product that can be run on its own—an application, command-line tool, and so forth—Xcode automatically sets the default executable to the target’s product. However, if you have a product such as a plug-in or framework, you must create an executable environment to specify a program to run and test your product with.

Even if your product generates an executable that can run on its own, you may want to customize the executable environment to specify command-line arguments for Xcode to pass to the program on launch, environment variables to set, and so forth. “Defining Executable Environments” describes executable environments in Xcode in more detail and explains how to modify executable settings.

A project can contain any number of executables. There is not a one-to-one correspondence between targets and executables, although Xcode automatically creates an executable environment for each target that creates a product that can be run on its own. You can, however, define multiple executable environments to use to test the product of a single target under different circumstances.

Product Information

In addition to the fundamental building blocks of the development process, your Xcode project also maintains a great deal of information about the items in your project and their current state. Figure 1-2 shows a representation of a project with this additional information.


Figure 1-2  An Xcode project

An Xcode project

Your Xcode project tracks:

The settings that an Xcode project tracks include:

Because active build configuration, choice of version control system, and SDK version are all attributes of the project, they must be the same for all targets in a project. For example, if you have a target that uses the Perforce source control system, you can’t have another target in the same project that uses the CVS system. You can, however, use cross-project references and dependencies to tie together targets in separate projects that use different version control systems.

A project can have multiple targets and multiple executables. However, there can be only one active target, one active build configuration, one active architecture, and one active executable. So, for example, if a project builds more than one application, only one executable—corresponding to one application—can be active and that’s the only executable you can debug in Xcode’s graphical debugger. If you want to debug both applications at once with the graphical debugger, you’ll have to build them in separate projects.

Renaming Xcode projects: Although you can change the names of the products that project produces (using the Product Name build setting), you cannot change the name of a project.

The Project Directory

When you create a project, Xcode creates a project directory to hold your project’s contents. The project directory contains the project package, which holds project metadata—as described in the previous section—and user information. The project package has the same name as the project and carries the extension .xcodeproj.

In addition to the project package, the project directory can also contain:

The Project Info Window

Xcode maintains information about a project at several levels, including project, target, and file. Information kept at the project level comprises general information, project build settings, project build configurations, and project comments. You use the Project Info window to view and edit this information.

To open the Project Info window, do one of the following:

The Project Info window contains the following panes:

General Project Attributes

Figure 1-3, shows the General pane of the Project Info window.


Figure 1-3  General pane of the Project Info window

General pane of the Project Info window

The General pane contains the following information:



< Previous PageNext Page > Hide TOC


© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-01-06)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.