Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Support

Switching from CodeWarrior to Xcode

With the release of Panther, developers now have a complete set of development tools from Apple. These tools, known as Xcode, are designed to streamline all your most common and time-consuming tasks. Xcode combines familiar user interface concepts with an array of development and performance technologies, all centered on a new integrated development environment (IDE).

Xcode offers key advantages to developers:

  • Rapid development of Mac OS X applications in C, C++, Objective-C, Java, and AppleScript.
  • Support for new Apple technologies, including code-generation optimizations for the PowerPC G5.
  • Distributed free with Mac OS X version 10.3. Xcode also ships with every new Apple computer and is available free by download to Apple developers.
  • A powerful user interface to proven open-source tools, such as GCC, java, jikes, and GDB.
  • Templates for creating applications, frameworks, libraries, plug-ins, Java applications and applets, and command-line tools.

This article is intended for developers who currently use CodeWarrior. It provides a brief overview of Xcode’s major components, describes the benefits of moving to Xcode from CodeWarrior, and tells you how to get started. For detailed information, see Moving Projects From CodeWarrior to Xcode.

Overview of Xcode

When Apple designed Xcode, they kept you, the developer in mind, and so the aim was to provide a powerful and easy-to-learn development environment to address the needs of C and C++ Carbon-based, commercial developers. Apple also wanted this environment to support the use of Apple tools for migrating developer projects and enabling them to utilize everything Mac OS X has to offer.

Xcode is for building fully integrated Mac OS X solutions—whether you are developing low-level components or high-level applications, whether you use Carbon or Cocoa, and whether you choose compiled C-based programming languages, Java or AppleScript.

Xcode is focused on improving productivity for developers—combining a high-performance UNIX-based development environment, the elements from a familiar user interface, and powerful performance technologies including Fix and Continue, ZeroLink, and Distributed Build.

Take Full Advantage of Mac OS X

Xcode enables the full expression of programming concepts with Mac OS X. When developing Xcode, careful attention was paid to developers writing in C, C++, Objective C, and Objective C++. Xcode also supports WebObjects with a Java environment, and workflow development with AppleScript.

Easy to Learn

The Xcode user interface is inspired by many of the best features of Apple’s iApps its and other popular applications. Where most IDEs are large, complex, and difficult to use, Xcode breaks that barrier, making the IDE easy to learn without diminishing its power and capability.

With Xcode, you can make the most use of your time by integrating performance analysis tools such as Sampler, MallocDebug, and Shark into the IDE. As a result, you are able to launch your application, from directly within the IDE, into a performance analyzer in order to gain greater insight into your application’s behavior, and identify strategies for optimizing its performance.

Flexibility

Xcode provides many features that you can customize to fit the way you work. In addition to the features you set in the Preferences window, with Xcode you can:

  • Customize Command-key equivalents so you can use the keystrokes you are most familiar with
  • Choose the editors to use for files in your project
  • Customize the toolbar for any project window
  • Use shell scripts in Xcode in several ways

Familiar Interface

CodeWarrior is a popular and powerful IDE; and so Xcode integrates familiar conventions from CodeWarrior, such as conventions for configuring basic views, with elements from Apple’s iApps, such as the inspector and configuration settings for components. Xcode also incorporates the ability to view separate windows for each source file and the ability to view editing windows within the single-window view.

The Components of Xcode

Xcode puts all the tools and components at your fingertips in an easy-to-navigate IDE so that you can make the best use of your time.

Edit Window

When you edit a file in Xcode, you have the choice of using a separate standalone editor window or editing the file directly in the project window or debugger window. Integrated into the editing environment are extensive tools for source navigation, documentation reference, and Help information.

Native Build System

Xcode includes a fast, accurate dependency system built into the IDE. While Xcode fully supports legacy Project Builder projects that use a JAM-based build system, all new projects and targets—including targets imported from CodeWarrior projects—use the native build system. Xcode’s new build system intelligently manages project dependencies, minimizing your pre-compile analysis of projects. Xcode also provides the capability of using multiple, network-connected systems to share build compilation efforts with Distributed Build. All this adds up to more rapid builds, faster turnarounds, and higher developer productivity.

Debugger

Basic debugging is very similar in CodeWarrior and Xcode. Xcode uses the open source GDB debugger and provides additional features, such as Fix and Continue and ZeroLink, to make debugging more efficient. Xcode supplies a graphical interface to GDB, but you can also use the command-line interface to get full access to any GDB feature not supported in the user interface.

SCM System

Xcode currently supports two systems: the open source standard Concurrent Versions System (CVS) and Perforce. Whichever system you choose, the Source Code Management (SCM) menu has the same commands. The number of supported commands is deliberately kept limited, but the commands are more tightly integrated into the environment. You will find the most commonly used source control commands available in Xcode.

Benefits of Moving to Xcode

Xcode fully supports new Apple technologies. Its gcc 3.3 compiler is built to optimize applications for the new PowerPC G5 processor. Developers can use AppleScript and Apple graphical development tools to quickly create native Mac OS X applications that take advantage of Apple’s rich Cocoa programming environment and Aqua user interface.

Xcode delivers performance improvements that are five times faster than the previous-generation developer tools from Apple, delivering significantly faster turnaround times for developers creating applications for Mac OS X.

Mach-O

Xcode provides a high level of integration with all the tools required for analyzing and developing applications based on the Mach-O executable format, the native binary format for the platform.

GCC 3.3 Compiler

Xcode uses the open-source GNU C Compiler, or GCC. When you compile C, C++, Objective-C, or Objective-C++ code in Xcode, you are using GCC. The default version of GCC for Xcode is 3.3.

ZeroLink

Xcode includes ZeroLink, which is used to speed up the edit-compiler-launch-debug cycle. It lets you bypass the linker, and instead have the executable load the .o files as needed. By linking only the object code needed to launch the application, instead of all the code, as in other development tools, Xcode dramatically reduces the debugging cycle. You spend less time waiting for builds and more time writing code.

Fix and Continue

Now you can make live code changes to a running application. Xcode’s Fix and Continue feature gives you near-instant turnaround while debugging. You simply make the edits, save the code, compile it, and instantly see the change take effect in your application running live in the debugger.

Distributed Builds Through Rendezvous

Project build times are greatly reduced through a Distributed Build feature that allows you to compile applications using multiple systems. This feature is fully Rendezvous-enabled to provide great configuration ease.

Xcode uses Rendezvous to find other computers on the network running Xcode. It then uses processor resources on idle machines during compilation to speed up the process even more. It allows you to deploy a dedicated Xserve build farm to do in minutes what would take hours on any single machine.

Hardware-based Performance Analysis

Xcode includes the Computer Hardware Understanding Developer tools (CHUD) for low-level system debugging and profiling in addition to software-based performance tools. One of the CHUD tools is Shark, an analysis tool that performs time-based sampling of the computer running your software to identify hot spots (places where your code is spending most of its time). Using Shark enables you to find specific routines that will benefit the most from optimization.

Documentation

Xcode addresses the chronic time loss you experience searching code and documentation by putting function and variable names at your fingertips. A code completion feature suggests complete named elements-pulled from API documentation and the current project index-before you have finished typing them.

So now, when you are writing a line of code and need a function, you can seamlessly look it up, find the reference, determine which function you need, and bring it over into your code. It is fast and direct.

All the documentation you need is built right into Xcode. This adds to the learnability of Mac OS X programming and to the robustness of being able to really get to all Mac OS X capabilities.

How Xcode and CodeWarrior Compare

Like CodeWarrior, Xcode is focused on the use of projects, targets, and files. But it also takes advantage of some popular interface features found in iApps and other consumer applications, such as groups of files and other items, fast searching for items, and a clean, relatively simple interface.

The developer environments for Xcode and CodeWarrior contain the same major components including a project window, text editor, build system, debugger, symbol navigation, find facilities, and help system.

Constructor to Interface Builder

CodeWarrior provides the Constructor application for designing user interfaces based on the PowerPlant framework. Xcode includes the Interface Builder application for creating graphical user interfaces for Mac OS X applications. Interface Builder works with both Carbon and Cocoa applications and lets you lay out interface objects (including windows, controls, menus, and so on), resize them, set their attributes, and make connections to other objects and to source code. The layout tools in Interface Builder include built-in support for the Aqua interface guidelines.

Interface Builder stores user interface resources in “nib” files. Nib files are a statically stored representation of the set of interface objects used by the application and their relationships which can be efficiently brought into memory when needed, reducing development time and making it easier to localize an application for different markets.

Profiler to Sampler

CodeWarrior provides the Profiler application for examining the behavior of a running application and fine-tuning performance. The equivalent in Xcode is the Sampler application, a performance-measuring application that analyzes a running program’s allocation of memory to locate hot spots.

ZoneRanger to MallocDebug

For tracking memory usage and bugs, Xcode provides the MallocDebug application, which helps debug memory problems that you would debug on Mac OS 9 with CodeWarrior’s ZoneRanger.

Xcode Transition: Doing It Right

Before you migrate a project to Xcode, you can take a few steps that will save you considerable time and effort later.

Converting to Carbon

You should first convert your code to Carbon using the latest version of CodeWarrior to smooth the transition.

Keep in mind that Carbon is a set of programming interfaces that allows applications to run natively in Mac OS X. If an application uses an older operating system model and older operating system APIs that are not part of Carbon, it cannot run reliably in Mac OS X, except in emulation mode.

Transitioning to Mach-O

After converting your code to Carbon, you should do a Mach-O transition.

Mach-O is the native executable format in Mac OS X. Applications that use Mach-O format have access to all native Mac OS X APIs, such as Quartz and POSIX, and can more easily support symbolic debugging with GDB.

Individual Headers to Framework-Style Headers

One important transition in moving to Mac OS X development is the switch from individual headers to framework-style headers in your source code files. A framework is a type of bundle that packages shared resources, such as a dynamic shared library and its associated resource files, header files, and reference documentation. An umbrella framework is a framework that includes a number of related frameworks.

This means that although CodeWarrior allows for a different prefix for each module, Xcode requires the same prefix file. The information in the framework-style header should be limited to the common pieces that you can use throughout.

Precompiled Header Mechanisms

Precompiled headers are binary files that represent the compiler’s intermediate form of the headers required to compile a source file, providing faster compile times. CodeWarrior and Xcode both support this feature with Prefix Headers.

Xcode allows one Prefix Header per target. If you use more that with CodeWarrior, you need to modify your source files to include just one per target.

C++ code can take full advantage of precompiled headers for improved build speed.

Moving from MSL Libraries to Apple Standard C/C++ Libraries

CodeWarrior supplies MSL libraries to create Mach-O style executables that run on Mac OS X only. In some cases, the MSL library calls through to the Mac OS X System framework library, and in some cases it provides missing features (such as wchar_t support, not available in Mac OS X prior to Panther).

If your CodeWarrior project is already building a Mach-O style executable, you should have an easier time in moving it to Xcode. If not, you should consider converting it.

Importing Compiles Your .plc Into a plist

Any packaged Mac OS X software requires an information property list file (appropriately named Info.plist). CodeWarrior projects that create similar types of software use a .plc file to supply this information.

When you import aproject into Xcode, the importer does extract property list setting information from the CodeWarrior project, but you should check the information and make any necessary additions or modifications. If your CodeWarrior project does not have a .plc file, you need to supply all the necessary information. You can read about differences between these approaches in “The Information Property List and .plc Files,” in Moving Projects from CodeWarrior to Xcode.

Code Differences

There are some code differences between CodeWarrior and GCC compilers.

GCC Does Not Recognize Most CodeWarrior #Pragmas

The GCC compiler dodify settings for a project.

Enabling CodeWarrior-Style Inline ASM

GCC supports CodeWarrior-style inline asm code. To enable this support, you add the following flag to your build settings:

-fasm-blocks

When you import a CodeWarrior project that uses inline asm into Xcode, this flag is not set automatically, so you will have to add it yourself.

The procedure is available in “Inline ASM,” in Moving Projects from CodeWarrior to Xcode.

For More Information

Posted: 2003-10-24