Mac OS X Reference Library Apple Developer
Search

Xcode Features Overview

Xcode is a highly customizable integrated development environment (IDE) with many features that let you create a pleasant and efficient working environment. This overview introduces you to Xcode features by looking at an existing Xcode project—CFLocalServer, which builds client and server programs using UNIX domain sockets. Don’t worry—you don’t need to know anything about UNIX. You’ll be looking at this project just to learn the layout of an Xcode project. This project builds more than one product, which is why it’s an interesting one to look at.

Before you get started, download CFLocalServer from the ADC Mac OS X Reference Library. Double-click the CFLocalServer.xcodeproj file to open the project in Xcode.

The Project Window

Every software product starts out as a project. A project is the repository for all the elements used to design and build your product—including source files, user interface specifications, sounds, images, and links to supporting frameworks and libraries. The most visible type of software product you can create with Xcode is an application, but that’s not the only kind of project you can create. You can also develop Automator actions, command-line tools, frameworks, plug-ins, and kernel extensions.

Hello project window

The project window is the control center for an Xcode project. This section briefly describes each of the components in this window, except for the editing pane, which is described in “Text Editor.”

The Toolbar

The project window toolbar (identified in contains buttons and other controls you can use to perform common operations.

The project window toolbarThe project window toolbar

You can customize what’s available on the toolbar.

Try it: Customize the toolbar.

  1. Control-click the toolbar and choose Customize Toolbar from the pop-up menu.

  2. Drag the Run/Debug icon from the sheet that appears to the space in the toolbar located between the Build and Run button and the Breakpoints button.

Groups & Files

Groups organize the files and information in a project—they don’t necessarily reflect the actual structure of the project directory or the way the build system views the files. Their purpose is to help you organize your project and quickly find project components and information. You can customize some of the default groups in the list and define groups of your own.

Xcode provides several built-in groups such as Targets, Executables, Bookmarks, and SCM (source control management). The first group listed is always the project group, which organizes all the components needed to build your product. The project group typically contains subgroups for your project’s source files, resource files, frameworks, and products.

To the right of the Groups & Files list is the detail view. The detail view is a flattened list of all the items that are currently selected in the Groups & Files list. You can quickly search and sort the items in the detail view, gaining rapid access to important information in your project.

Try it: Explore the groups in the CFLocalServer project.

Text Editor

In addition to displaying content that you can edit, the text editor provides a navigation bar at the top, and a gutter and focus ribbon to the left of the content. You can view and edit a source file within the project window by selecting the file in the Groups & Files list. If you prefer to view and edit a source file in its own window, double-click the file in the Groups & Files list.

The text editor view

The gutter displays line numbers, as well as information about the location of breakpoints, errors, or warnings in the file.

The focus ribbon, as its name suggests, helps you to concentrate your attention on parts of your code by:

The bar along the top of the editor contains several menus and buttons that let you move between files you’ve viewed, jump to symbols, and switch to other open files.

Figure 1-1  Text editor navigation bar

Text editor navigation bar

Although you can hold the pointer over each item to see a tooltip that provides a description of each item, these items need more explanation:

Try it: Navigate through a file in the CFLocalServer project using the function pop-up menu. Then open its counterpart.

  1. Double-click the Common.c file.

  2. Place the cursor anywhere in the code.

  3. Open the function pop-up menu and choose a function name.

  4. Click the Counterpart button to open the header file associated with the Common.c file.

Two other text editor important features—code completion and Quick Help—are described next.

Code Completion

Code completion offers you an alternative to typing long method names, argument lists, and other symbols. When you’ve entered enough letters for Xcode to make a reasonable guess, you’ll see the suggestion appear as dimmed text. To accept the suggestion, press Tab. To see a list of all possible completions, press the Esc key.

For symbols that include parameters, such as methods, Xcode optionally inserts placeholders for the arguments. To move to the next placeholder, press Control–/.

To disable or enable code completion, use the Automatically Suggest menu in the Code Sense pane of Xcode preferences.

Try it: Let Xcode complete your code.

  1. Anywhere in the Protocol.h file, enter NS then press Esc to see the completion list that Xcode built so far.

  2. In the list that appears, choose any item and press Return. Xcode enters the item you chose.

  3. Delete the entered text so the program will compile.

Quick Help

Finding technical information about an unfamiliar technology or API symbol is an important and often time-consuming activity for software developers. To view the reference documentation for a symbol in your code, Option–double-click it. Quick Help opens inline to show you the reference documentation for that symbol. If you prefer to view the header file for the symbol, click the .h button at the top of the Quick Help window. If you would like to see the complete reference document, click the book icon.

Quick Help closes automatically when you start typing again. If you want to keep Quick Help open so you can use it like an inspector, simply move it.

Try it: Look up information about a symbol in the Client.c file.

  1. In the ConnectionGotData function, find kCFSocketDataCallBack.

  2. Insert the cursor in that symbol, then press the Option key and double-click the mouse.

The Documentation Window

You can use the Documentation window to search through all developer documentation (API reference, guides, sample code, technical notes, release notes, and technical Q&A documents). As you enter a term in the search field, Xcode simultaneously performs API reference, document title, and full text searches.

Try it: Find information using the Documentation window.

  1. Open the Documentation window by choosing Help > Documentation.

  2. In the search field, enter NSMuta.

  3. Click a few different results to view the documentation.

  4. Double-click any result to view it and also close the search results view.

Targets and Build Phases

A target contains the instructions for building a finished product from a set of files in a project—for example, a framework, library, application, or command-line tool. A simple Xcode project has just one target that produces one product. A larger development effort with multiple products may require a more complex project containing several related targets. For example, a project for a client-server software package may contain targets that create a client application, a server application, command-line tool versions of the client and server functionality, and a private framework that all the other targets use.

Build phases are instructions that Xcode follows to build a target. Each build phase consists of a list of input files and a task to be performed on each of those files. Common build phases include compiling files, linking object files, and copying resource files.

Try it: Look at the targets and build phases in the CFLocalServer project.

  1. Click the disclosure triangle next to the Target group.

  2. Click the disclosure triangles next to each of the targets in the Target group.

The CFLocalServer project has three targets. One builds a server program, one builds a client application, and another is a target whose purpose is to sequentially build the other targets. You can customize how a project is built by adding phases. To add a phase, choose Project > New Build Phases.

Build Settings

A build setting is a variable that contains information used to build a product. For each operation performed in the build process—such as compiling Objective-C source files—build settings control how that operation is performed. For example, the information in a build setting specifies the options Xcode passes to the tool—in this case, the compiler.

Each target can specify one or more sets of build settings, called build configurations. Targets are preconfigured with two build configurations, debug and release. The debug build configuration specifies build settings that generate products containing information that is useful during development, such as debug symbols. The release build configuration specifies build settings appropriate for products that are ready to deploy to your customers.

Try it: Find out which build configurations and settings are available for the CFLocalServer project.

  1. In the Groups & Files list of the project window, select the project group and then click the Info button in the toolbar.

  2. In the window that appears, click Build to display the Build pane of the Info window. You’ll see the active configuration and a list of the build settings for that configuration.

  3. Open the Configuration pop-up menu to see what other configurations are available. Choose a configuration you haven’t yet looked at.

  4. Compare the build settings for that configuration with the first configuration you looked at.

  5. Click a build setting. Look at the bottom of the window to see its description.

Build Products

By default, Xcode places the built application bundle inside your project’s build folder. You can run a built application from the Finder by double-clicking the application icon located in Debug or Release folder in your project’s build folder. Which folder depends on whether the active build configuration is debug or release.

Try it: Check the build location for the the CFLocalServer project and then change it.

  1. In the Groups & Files list of the project window, select the project group and then click the Info button in the toolbar.

  2. Click General to see the current build location.

  3. Change the location of the build products by selecting “Custom location”, clicking Choose, and navigating to a location.

Preferences and Keyboard Shortcuts

Xcode preferences let you customize just about everything in the development environment including the behavior of the text editor, where build products are stored, code colors and indentation, code repositories, and the content shown in Quick Help.

One popular set of preferences is Key Bindings, which lets you change the keyboard shortcuts for actions accessible through menu items or the keyboard, such as paging through a document or moving the cursor. You can choose a predefined set of keyboard shortcuts for menu items and other tasks, or you can create your own set. The predefined sets include sets that mimic BBEdit, Metrowerks, and MPW.

Try it: See what preferences are available.

  1. Choose Xcode > Preferences.

  2. Click each button at the top of the window to see the preferences that pertain to that topic—General, Code Sense, Building, and so on.




Last updated: 2009-07-22

Did this document help you? Yes It's good, but... Not helpful...