
Xcode, Apple's tool suite and integrated development environment (IDE), is
the fast and easy way for developers to create applications for Mac OS X Tiger.
Xcode is designed to let you take advantage of all the great technologies that ship
in Mac OS X. And using Xcode is the way you build a universal application that runs on both the Intel and PowerPC architectures.
Xcode 2.3, released in May 2006, is built on the foundation of earlier versions of the Xcode project that have steadily
introduced more and more tools, enhancements and performance improvements. Xcode is a mature and robust tool set,
including such technologies as Code Sense and advanced build management.
If you are new to Xcode, the first part of this article shows you how to get started, so you can begin creating universal binaries and
take full advantage of all of the latest technologies in Mac OS X Tiger. To get started, just become an Apple Developer Connection member. A free ADC Online membership provides access to the latest Xcode updates
and other developer tools. And if you are already using Xcode, this article points out some of the key
changes and enhancements that come with Xcode 2.3. Either way, be sure to download this latest version right away.
Working with Xcode
First and foremost, Xcode is designed to let you work with code by means of a
intuitive interface. Because not everyone works the same way, Xcode is a
very flexible tool that provides many different ways to customize the
development process. One of the most visible ways you can customize Xcode is to
configure your development environment into one of the three following layouts:
- Default, which provides a main window that gives an overview of your project along with separate or attached editor windows and separate build and debug windows.
- Condensed, which provides a smaller simpler project window with an outline view of your project and separate windows for editing, debugging, and building.
- All-in-One, which provides a single project window that lets you perform all of your editing, debugging, searching, and building tasks in a single window.
No matter which layout you choose to use, there are two primary parts to the Xcode user interface in which you work with the various files and resources that make up your project: the
Groups & Files List and the Detail View
The Groups & Files List
The Group & Files list provides an outline view of your project. This lets
you organize and manage all the items that make up a project in manageable
chunks. At the top of the list is the project group which contains all of the
files, frameworks, and libraries that are used by your project. The items in the
project group are not organized according to how they exist on the filesystem, but rather
into more distinct and logical groups that you can modify to suit your needs.
Under the project group is a set of smart groups. These groups collect files and other information that match certain rules or patterns. Xcode provides several built-in smart groups that put frequently used information a mouse-click away. For example, the Targets group contains all of the targets that a project is set up to build. The Errors and Warnings group lists all of the build warnings and errors generated by the last build. And the Project Symbols group lists all of the symbols defined in your project.
In addition, you can define your own smart groups. For example, you might want to create a smart group that shows only files that end in the .cpp extension that are in your project.
The Detail View
When you click on a group in the Groups & Files list, the detail view
presents a flat list of the items contained in that group. For example, if you
select the project group, all of the files in the project are displayed.
You can easily narrow the list of files displayed in the detail list by typing
into the Search field at the top right of the window. As you type, the list
dynamically updates to show just those items that match the string you are
typing into the search box, as shown in Figure 1.
Figure 1: Xcode Detail List
Customizable Build System
Project management and dependency tracking is only one aspect of Xcode's project management features. Generally speaking, the basic rule of dependency tracking can be stated thusly: When one
file is modified, some processing must occur on all of the files that depend on the modified file. For example, changing an Objective-C source file causes Xcode to trigger a built-in
rule that invokes the GCC compiler on that file.
Xcode gives you the flexibility to define your own custom build rules. This way you can specify virtually any kind of processing required to bring the project's targets up to date. You can use
custom shell scripts, makefiles, or external build systems.
Saving time with Code Sense
The Xcode source editor also offers source code completion for Objective-C,
C, C++, AppleScript, and Java source files. Code completion, or Code Sense,
parses your code to build a store of information about the symbols and their
types defined in your project. As you begin to type an identifier or keyword, Code Sense
presents a popup list of likely matches, based on the context and location
within the source file. This functionality not only saves you time; it can also help you learn the names of the classes, methods,
and properties available in a given framework. Figure 2 shows Code Sense working
on the NSMutableArray class. Immediately after typing the class name,
the completion list appears:
Figure 2: Code Sense Completion Menu
After selecting the allocWithZone method, Code Sense inserts the
call into your code, complete with template arguments, as shown in Figure 3:
Figure 3: Code Sense—allocWithZone Method Selected
The template argument is already selected and the editor is ready for you to type the name of the actual argument.
Collaboration with Version Control
Xcode provides a common interface to several version control systems:
CVS, Subversion, and Perforce. Xcode makes it easy to perform most
version control tasks as you work, such as updating a project and committing changes
to a file. It also keeps track of what files you've
modified in your local copy of the project and can indicate the status
of those files to you.
Integrated Unit Testing
Test-first development and unit testing have become
widely accepted in software development. Unit testing helps to accelerate your
application's development by giving you the confidence to re-factor your
application and know that it still works the way you expect. As well, unit
tests can help you prevent regressions for issues in your code base that you
have already taken care of.
Since version 2.1, Xcode includes integrated unit testing directly in the IDE and comes
with support for Objective-C using OCUnit, and for C++ using CPlusTest. Using
either framework you can create test bundles for Cocoa and Carbon applications.
You can also easily integrate other unit test frameworks as well, such as JUnit.
Once created, unit tests can be run every time you build your project and will
report any errors in the Build Results window, giving you instant feedback that
your application is working the way that you expect.
Customizable Key Bindings
By default, Xcode uses a set of key bindings that builds on top of the
standard set of bindings used by every application, including a large number of bindings familiar to Emacs
users. However, if you've spent a
lot of time working in another environment, your fingers might have a built-in
muscle memory that you'd like to preserve. To help you out, Xcode lets you change the bindings to be compatible with BBEdit,
Metrowerks, or MPW. In addition, you can configure your own custom set of key
bindings and customize this part of your day-to-day experience any way you
choose.
New in Xcode 2.3
Now let's take a look at some of the new enhancements to Xcode 2.3, including
support for DWARF debugging information, dedicated network builds, and overall
Xcode improvements in a number of areas.
Support for DWARF
Xcode 2.3 supports the DWARF standard for debugging information. DWARF (which stands for "Debugging with Attributed Record Formats") is an open standard, originally
developed by Bell Labs. DWARF is a more descriptive format than Stabs (the current debugging format), resulting in better fidelity when debugging in Xcode. And yet DWARF is also
more efficient than Stabs, which results in less space required for debugging information. For more information on the DWARF standard, refer to the DWARF Debugging Standard website.
While Xcode now supports the DWARF format, the Stabs format is still the default setting. To change the debugging format:
- Open the project and display the Build Settings inspector.
- Select Build Options from the Collection popup list.
- Select one of the two DWARF options in the Debug Information Format popup list: either DWARF, or DWARF with dSYM file (as shown in Figure 4:
Figure 4: Xcode Build Settings Inspector
If you choose the DWARF with dSYM option, Xcode will use DWARF and produce a separate symbol file with the extension .dSYM, instead of using individual object files for
symbol information. This option allows you to distribute a single executable with debugging information, accompanied by one file with symbol information. Keeping a single
symbol file makes it easier to share with other team members (QA, for example), however, it does add time and an extra step to the build process.
If you have ZeroLink enabled, Xcode will not generate a .dSYM file, even if you have chosen the DWARF with dSYM option; this combination is not supported. Do not use the dSYM
option with targets that produce static libraries or object files. Use the DWARF option for these cases.
Dedicated Network Builds
Dedicated network builds is an important enhancement to the Xcode 2.3 build system. While shared workgroup builds (distcc) are best for projects with
about ten builders or less, dedicated network builds are targeted for large projects with over a dozen builders. Since it is intended for use with large projects,
dedicated network builds use more resources on remote machines performing the build (remote build computers are called "volunteers"). For this reason, using a
machine as both a developer and builder workstation is not recommended.
Distributed build settings are located on the Distributed Builds Preference Pane. To advertise your computer as a dedicated network build volunteer, open the
Distributed Builds Preference pane and check Share my computer for dedicated network builds. To set up a dedicated network build, check the Distribute via option, and
choose Dedicated network build from the popup list, as shown in Figure 5:
Figure 5: Xcode Distributed Builds Preferences Pane
For more information on setting up and optimizing distributed builds, see the Distributing Builds Among Multiple Computers in the Xcode 2.3 User Guide.
General Xcode Improvements
Improved Support for the Netwide Assembler (NASM)
Xcode 2.3 adds a new file type for NASM files. Files with the extension .nasm will be processed by the new built-in rule, which invokes the assembler. Note that
using NASM is only applicable when building for the Intel architecture.
For more information on NASM command-line parameters, see the NASM man page.
Improvements for Sharing Precompiled Headers
Precompiled headers can now be shared between targets that share the same prefix header and precompiled header directory. This option causes the compiler to ignore
search path options (-I, and -F). This might cause targets that use the same prefix header, but that have different search paths, to incorrectly
share the same precompiled header. In this case, sharing precompiled headers must be disabled.
Improved Dependency Checking
Xcode now performs dependency checking on targets that link against a framework or library. This means that if the framework or library has changed, Xcode will relink the target.
Similarly, the Clean Confirmation sheet now gives you the option of also cleaning target dependencies.
Documentation Enhancements
One of the most useful features of Xcode is the documentation browser. Using it, you can quickly browse the APIs for the various frameworks installed on the system as
well as perform full text searches on the complete set of developer documentation installed in the /Developer/ADC Reference Library folder.
One of enhancements to the documentation browser is the ability to drag bookmarks out of the browser window, and drop them into text files. Doing so results in the URL
of the associated document being inserted into the text. You could use this functionality to link your source code directly to a specific help topic. For example, if you are
working with the NSTextView class, why not drop a bookmark to the NSTextView class reference directly into your source code?
Clicking the URL will open a browser window and take you directly to the reference topic.
Many symbol names are hyperlinked in the Developer Reference Library, but not all of them are. In Xcode 2.3, you can display help for non-hyperlinked symbol names
in documentation windows by option-double-clicking on the symbol name. This will take you directly to the help for the symbol.
Conclusion
The latest release of Xcode includes a number of new enhancements to the product, both
building on the foundation of previous versions and enabling future
capabilities. And the GCC 4.0 compiler means that your
finished applications will run faster than ever.
How You Can Get Started
Getting started is easy. If you are not yet an ADC member, become one by signing up on the ADC Member Site.
A free ADC Online membership provides access to the latest Xcode updates
and other developer tools. An ADC Select
Membership goes further by providing shipping versions of Mac OS X Tiger and
Xcode 2.3 on disc, along with download access to Mac OS X Tiger Server.
Select membership also includes direct, one-on-one consultation with
Tiger support engineers, a discount on hardware through the ADC Hardware
Purchase Program, and ongoing access to pre-release software.
For More Information
Posted: 2006-05-31
|