< Previous PageNext Page > Hide TOC

Porting Tips

Although many applications have been created from scratch for Mac OS X, many more have been ported from existing Windows, UNIX, or Mac OS 9 applications. With the introduction of the G5 processor, some application developers are even taking the step of porting their 32-bit applications to the 64-bit memory space offered by the new architecture.

The Reference Library > Porting section of the Apple Developer Connection Reference Library contains documents to help you in your porting efforts. The following sections also provide general design guidelines to consider when porting software to Mac OS X.

In this section:

64-Bit Considerations
Windows Considerations
Carbon Considerations


64-Bit Considerations

With Macintosh computers using 64-bit PowerPC and Intel processors, developers can begin writing software to take advantage of the 64-bit architecture provided by these chips. For many developers, however, compiling their code into 64-bit programs may not offer any inherent advantages. Unless your program needs more than 4 GB of addressable memory, supporting 64-bit pointers may only reduce the performance of your application.

When you compile a program for a 64-bit architecture, the compiler doubles the size of all pointer variables. This increased pointer size makes it possible to address more than 4 GB of memory, but it also increases the memory footprint of your application. If your application does not take advantage of the expanded memory limits, it may be better left as a 32-bit program.

Regardless of whether your program is currently 32-bit or 64-bit, there are some guidelines you should follow to make your code more interoperable with other programs. Even if you don’t plan to implement 64-bit support soon, you may need to communicate with 64-bit applications. Unless you are explicit about the data you exchange, you may run into problems. The following guidelines are good to observe regardless of your 64-bit plans.

There are several documents to help you create 64-bit applications. For general information about making the transition, see 64-Bit Transition Guide. For Cocoa-specific information, see 64-Bit Transition Guide for Cocoa. For Carbon-specific information, see 64-Bit Guide for Carbon Developers.

.

Windows Considerations

If you are a Windows developer porting your application to Mac OS X, be prepared to make some changes to your application as part of your port. Applications in Mac OS X have an appearance and behavior that are different from Windows applications in many respects. Unless you keep these differences in mind during the development cycle, your application may look out of place in Mac OS X.

The following list provides some guidelines related to the more noticeable differences between Mac OS X and Windows applications. This list is not exhaustive but is a good starting point for developers new to Mac OS X. For detailed information on how your application should look and behave in Mac OS X, see Apple Human Interface Guidelines. For general porting information, see Porting to Mac OS X from Windows Win32 API.

Carbon Considerations

If you develop your software using Carbon, there are several things you can do to make your programs work better in Mac OS X. The following sections list migration tips and recommendations for technologies you should be using.

Migrating From Mac OS 9

If you were a Mac OS 9 developer, the Carbon interfaces should seem very familiar. However, improvements in Carbon have rendered many older technologies obsolete. The sections that follow list both the required and the recommended replacement technologies you should use instead.

Required Replacement Technologies

The technologies listed in Table 8-1 cannot be used in Carbon. You must use the technology in the “Now use” column instead.

Table 8-1  Required replacements for Carbon

Instead of

Now use

Any device manager

I/O Kit

Apple Guide

Apple Help

AppleTalk Manager

BSD sockets or CFNetwork

Help Manager

Carbon Help Manager

PPC Toolbox

Apple events

Printing Manager

Core Printing Manager

QuickDraw 3D

OpenGL

QuickDraw GX

Quartz and Apple Type Services for Unicode Imaging (ATSUI)

Standard File Package

Navigation Services

Vertical Retrace Manager

Time Manager

Recommended Replacement Technologies

The technologies listed in Table 8-2 can still be used in Carbon, but the indicated replacements provide more robust support and are preferred.

Table 8-2  Recommended replacements for Carbon

Instead of

Now use

Display Manager

Quartz Services

Event Manager

Carbon Event Manager

Font Manager

Apple Type Services for Fonts

Internet Config

Launch Services and System Configuration

Open Transport

BSD sockets or CFNetwork

QuickDraw

Quartz 2D

QuickDraw Text

Core Text

Resource Manager

Interface Builder Services

Script Manager

Unicode Utilities

TextEdit

Multilingual Text Engine

URL Access Manager

CFNetwork

Use the Carbon Event Manager

Use of the Carbon Event Manager is strongly recommended for new and existing Carbon applications. The Carbon Event Manager provides a more robust way to handle events than the older Event Manager interfaces. For example, the Carbon Event Manager uses callback routines to notify your application when an event arrives. This mechanism improves performance and offers better mobility support by eliminating the need to poll for events.

For an overview of how to use the Carbon Event Manager, see Carbon Event Manager Programming Guide.

Use the HIToolbox

The Human Interface Toolbox is the technology of choice for implementing user interfaces with Carbon. The HIToolbox extends the Macintosh Toolbox and offers an object-oriented approach to organizing the content of your application windows. This new approach to user interface programming is the future direction for Carbon and is where new development and improvements are being made. If you are currently using the Control Manager and Window Manager, you should consider adopting the HIToolbox.

Note: The HIToolbox interfaces are available for creating 32-bit applications only. If you are creating 64-bit applications, you should use Cocoa for your user interface instead.

For an overview of HIView and other HIToolbox objects, see the documents in Reference Library > Carbon > Human Interface Toolbox.

Use Nib Files

Nib files, which you create with Interface Builder, are the best way to design your application interface. The design and layout features of Interface Builder will help you create Aqua-compliant windows and menus. Even if you do not plan to load the nib file itself, you can still use the metrics from this file in your application code.

For information about using Interface Builder, see Interface Builder User Guide.



< Previous PageNext Page > Hide TOC


© 2004, 2008 Apple Inc. All Rights Reserved. (Last updated: 2008-10-15)


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.