Start a Project
This chapter describes how to start a new Xcode project, either by creating a project from scratch, or by opening an existing project. When you’ve got your projects open, go to “Get Oriented” to learn more about using Xcode.
Create a Standalone Project
If you want to start a new software development undertaking using Xcode, you need to first decide whether you need a single project or multiple related projects. For a simple app or utility, a single project should suffice. However, if you have several related executables that need to link to a custom library, you probably want at least a separate project for the library, and possibly a separate project for each executable.
Start developing a software product by creating a project. All software products require a project. The project organizes the files and resources needed to build one or more products, such as applications, plug-ins, and command-line tools.
If you have two or more closely related projects, create a workspace and add your projects to it, as described in “Create a Workspace to Work with Multiple Related Projects.”
Preconfigure the New Project
The new project dialog shows options tailored for the project’s platform (iOS or Mac) and product type (app, plug-in, and so on). Figure 2-1 shows the options available for a new iOS project.
With storyboards, you design iOS user interfaces using scenes and scene transitions (known as segues). Each scene contains a view controller and its view hierarchy. Scenes also have a parent-child relationship between them, which specifies how one scene flows to another, and how data is transferred between scenes. Segues specify the visual transition from one scene to another.
To use storyboards to design user interfaces in your project, select the “Use Storyboards” option.
See View Programming Guide for iOS for details about using storyboards.
Use Core Data
With Core Data, you design the data model of your app using a graphical entity-relationship editor. Note that this is an advanced technology that is not required for creating simple applications. You can use Core Data in iOS and Mac projects.
To use Core Data in your project, select the “Use Core Data” option.
See “Edit Data Model Documents” for more information.
Use Automatic Reference Counting
Automatic Reference Counting (ARC) is a technology that automates memory management for Objective-C objects. ARC makes memory management much easier, greatly reducing memory management problems in your project.
To use Automatic Reference Counting, select the “Use Automatic Reference Counting” option.
For more information on ARC, see Transitioning to ARC Release Notes.
Use Unit Tests
Using unit tests in your project helps ensure that the modifications you make to your code do not break existing functionality. Unit tests are one of the essential building blocks of test-driven development.
To use unit testing in your project, select the “Include Unit Tests” option.
To learn more about unit tests, see Xcode Unit Testing Guide.
Create a Git Repository For Your New Project
You can create a local Git repository when you save the new project (Figure 2-2). This is the easiest way to add source control to a project (see “Keep Track of Changes with Source Control” for more information).
Create a Workspace to Work with Multiple Related Projects
A major feature of Xcode is the ability to create a container for multiple projects that you can use to group Xcode projects and other related files. This container is referred to as a workspace. All the projects in the workspace share the same build directory. Putting your related projects in the same workspace affords you several benefits, including:
One project can use the products of another project while building.
If one project depends on the products of another in the same workspace, Xcode can detect this and automatically build the projects in the correct sequence.
Because all the files in one project are visible to all the other projects in the workspace, you don’t need to copy shared libraries into each project folder separately.
Indexing is done across the entire workspace, extending the scope of content-aware features such as code completion.
Start a multiproduct development endeavor by creating a workspace. A workspace serves as a common container for several related projects.
You can add an existing project to the workspace, or Control-click in the structure navigator below the existing projects and choose New Project to create a project in the workspace.
Add an existing project to a workspace to add a product to a multiproduct development endeavor. When you need to work on two or more related projects, you can add them to a workspace so that you can create interproject relationships.
Because each project retains its individual identity, a project can be included in more than one workspace or removed from a workspace without affecting the project. The workspace file itself merely contains pointers to the projects and other files that the workspace includes, plus a minimal amount of data such as schemes stored in the workspace. The pointers to the source files, included libraries, build configurations, and other data are stored in the project files.
If the build product of one project in a workspace is dependent on the build product of another project in the workspace (for example, if one project builds a library used by the other project), Xcode discovers such implicit dependencies and builds in the correct sequence. If you don’t want one project to use the product or files in another project that’s in the same workspace, you need to adjust your build settings accordingly. See “Configure Your Project” for help in finding and understanding the build settings interface in Xcode.
Before you build, be sure you’ve created the scheme or schemes you need. See “Customize Product Actions” for more information on schemes.
Check Out a Working Copy from Your Source Control Repository
If your Xcode project is in a Git or Subversion repository, you can check out your project from the repository and open it in Xcode. See “Keep Track of Changes with Source Control” for more information on using source control in Xcode.
Close a Project or a Workspace
Choose Close Project or Close Workspace from the File menu to close a project or workspace. Xcode remembers which windows you had open and how they were configured, and restores them when you reopen the project or workspace.
© 2013 Apple Inc. All Rights Reserved. (Last updated: 2013-04-23)