Maintain Your Code and Other Resources in Projects or Workspaces

Apps you create in Xcode require a project, which keeps the necessary files and resources organized. You start a project by choosing File > New > New Project. Xcode opens a new workspace window and displays a dialog in which you choose a project template. Xcode provides built-in templates for developing common styles of iOS and Mac apps. These templates include essential project files that help you start your development effort quickly.


You view the names of project files in the project navigator. When you select a file in the project navigator, the file’s contents appear in the appropriate editor or viewer. In this screenshot, an implementation file (APAViewController.m) is selected in the project navigator, and the file’s contents appear in the source editor.


A Project Is a Repository of Files and Resources for Building Apps

A project contains the elements needed to build one or more apps (or other software products, such as command-line tools and plug-ins). The project also maintains the relationships among these elements. These elements include:

By selecting the project name in the project navigator, you open the project editor. You can use the project editor to specify every aspect of how your apps should be built, from the version of the software development kit (SDK) to specific compiler options. In this screenshot, the Adventure project is selected in the project navigator and in the project editor. The project editor displays the Info pane for the Adventure project.


When you create a project, Xcode provides two standard project-level build configurations: debug and release. These configurations differ mostly in whether they include debug information and in the degree to which each build is optimized. These two build configurations are probably sufficient for your product development needs. Most developers never need to change the values of the vast majority of build settings.

To add more build configurations, open the project editor, duplicate one of the project’s existing configurations, and then modify its settings. For example, you might configure a build that’s fully optimized but that also includes debug information in order to debug your optimized code.


Apply App-Specific Settings to a Target

Every project contains at least one target. A target specifies a product to build, such as an iOS or Mac app. Select a target in the project editor to view and modify the target’s settings. In the screenshot below, the Adventure project is selected in the project navigator, and the Adventure iOS target is selected in the project editor. The project editor displays the General pane for the target.


The General pane for a target shows basic settings that you occasionally check and possibly edit. You typically assign values for these settings elsewhere during the app development process, for example, in dialogs that appear when you create a new project.

For an iOS app, the General pane contains these sorts of target settings:

For a Mac app, the General pane contains these sorts of target settings:

Add Technology Features to a Target

To add various Apple technologies—such as iCloud, Game Center, In-App Purchase, and Maps—to your app, select its target in the project editor and select the Capabilities tab. Click a switch to On to add a capability. Xcode adds the necessary entitlements file to your project and links the target to the necessary frameworks.


Override Build Settings for a Target

A target also contains instructions—in the form of build settings and build phases—for building a product. A target inherits the project’s build settings. Although most developers seldom need to change these, you can override any of the project’s build settings by specifying different settings at the target level. Select a target in the project editor to modify the target settings in the Info, Build Settings, or Build Phases pane.

Workspaces Extend the Scope of Your Workflow

To group Xcode projects and other related files, you can create a workspace. Putting your related projects in the same workspace affords you several benefits. For example:

You create a workspace by choosing File > New > Workspace. After you create a workspace, you can create new projects within it and you can add existing projects to it.

Close and Reopen a Project or a Workspace

To close a project or workspace, choose File > Close Project or File > Close Workspace. Xcode remembers which windows you had open and how they were configured, and it restores them when you reopen the project or workspace.