< Previous PageNext Page > Hide TOC

Preparing a CodeWarrior Project for Importing

This section describes steps you can take to modify your CodeWarrior project before importing it into Xcode. Taking an incremental approach should make it easier to get your project building successfully in Xcode.

Important: It is recommended that you use CodeWarrior Pro version 8.3 or later for projects that you will import into Xcode. You are more likely to experience problems with older versions of CodeWarrior.

Note: This chapter describes preparation for converting a project that builds an application, but converting a project that builds shared libraries or other types of software requires many of the same steps.

In this section:

Convert Classic Applications to Use Carbon
Use the Application Package Type
Build the Application in the Mach-O Format
Remove Unnecessary Targets From the Project


Convert Classic Applications to Use Carbon

If you have a classic application—that is, an application designed for versions of the Mac OS earlier than Mac OS X—you should convert your code to use Carbon. Carbon is a set of programming interfaces that allows applications (including those originally designed for Mac OS 8 and 9) to run natively in Mac OS X. If an application uses older Mac OS APIs that aren’t part of Carbon, it cannot run reliably in Mac OS X, except in Classic (or emulation) mode.

The amount of effort required to convert a project to Carbon depends on its complexity and on the programming tactics and Mac OS APIs it uses. For full information, see Carbon Porting Guide.

Use the Application Package Type

You should set the Project Type setting for your CodeWarrior project to Application Package. Packaging an application consists of putting the application’s code and resources in prescribed directory locations inside the application bundle.

Note: A bundle is a directory in the file system that stores executable code and the software resources related to that code. Application packages are presented by the Finder as a single file.

To build an application as a package, you choose Application Package in the Project Type pop-up in the PPC Target pane. When you create a project from CodeWarrior stationery that uses one of the bundled types, such as “C Toolbox Carbon Bundle,” the Project Type is automatically set to Application Package.

Important: You may want to change application package type at the same time you switch to the Mach-O executable format, described in the next section. If so, you’ll set the project type on the PPC Mac OS X Target pane.

Packaged applications require an information property list, named Info.plist. “The Information Property List and .plc Files” describes this list, as well as differences in how to create it in CodeWarrior and Xcode.

Build the Application in the Mach-O Format

Mach-O is the native executable format in Mac OS X and is the only format supported by Xcode. 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. However, Mach-O applications cannot run in earlier versions of the Mac OS. For a summary of the advantages and issues of using Mach-O format, see “Use the Mach-O Binary Format” in Performance Overview.

If your project currently builds a CFM application or library, you may want to add a target to the project to build a Mach-O version. This will allow you to isolate changes you’ll need for Mach-O before switching to Xcode. And you’ll still benefit from the automated setup performed when you import the project into Xcode. However, for a simple project, you may end up doing extra work.

Conversely, if your CodeWarrior project is not particularly complex, you may want to import it directly into Xcode (and switch to the Mach-O executable format at the same time). If you do, many changes will be handled automatically, including changing your linker settings and moving from MSL libraries to the standard C and C++ libraries. A disadvantage is that you’ll be making more changes in a new environment, where problems may be harder to isolate, so this approach isn’t recommended for more complex projects.

Whichever approach you take, you will still have some work to do after importing, as described in “After Importing a Project.”

Convert to Mach-O Format

“C and C++ Libraries” describes differences between the CodeWarrior MSL libraries and the standard C and C++ libraries for Mach-O. To build your application in Mach-O format, you’ll need to make these changes:

The sections that follow list additional steps you’ll need to take in converting to use Mach-O format.

Use Framework Headers

“Framework-Style Headers” provides background on working with framework-style headers. To continue making the switch to a Mach-O target, you’ll need to take these steps to start using framework headers:

These steps are recommended, but not required.

Use C99 Standard in Language Settings

Applications that change from using Universal Interfaces to using framework-style include statements (in either CodeWarrior or Xcode), must conform to the C99 standard, as described in “Conform to the C99 Standard.” In CodeWarrior, you can select the “Enable C99 Extensions” setting on the C/C++ Language pane in the Target Settings window.

Migrate from MSL to System C and C++ Libraries

“C and C++ Libraries” describes differences between the libraries you use in CodeWarrior and Xcode. To continue the switch to a Mach-O target, perform the following steps to change libraries:

Replace Your Prefix File

“Precompiled Headers and Prefix Files” describes differences in how you use prefix files in CodeWarrior and Xcode. To continue the switch to a Mach-O target, you’ll have to move away from the CodeWarrior precompiled headers. You can do that in one of two ways:

Test Your Mach-O Target

At this point you should be ready to test your Mach-O target.

Remove Unnecessary Targets From the Project

To simplify the conversion process even further, you can make a copy of the project and delete any targets other than the targets you will import into Xcode. That will make importing faster and the resulting project will have just the desired target. Of course, you can also delete unneeded targets after importing into Xcode.



< Previous PageNext Page > Hide TOC


© 2003, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-10-26)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.