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

Porting Overview

Apple provides powerful tools and robust programming interfaces to move your code to Mac OS X, where you can take full advantage of a stable customer base and dynamic technologies. Mac OS X includes a wide assortment of advanced features and utilities, such as the Aqua user interface, the Quartz graphics system, the Xcode graphical IDE, Interface Builder, and the PackageMaker installation tool. Mac OS X offers powerful functionality in several areas that make porting your applications to the Macintosh easy, including the solid Darwin foundation, a great visual interface, an enhanced file system architecture, free development tools, and convenient packaging and distribution tools. Whether you are porting from UNIX, Windows, or Java, you can turn it into an application with the most usable interface on the planet.

Based on Darwin, which is derived from BSD UNIX, Mac OS X enjoys all the benefits of a robust UNIX system, including protected memory, preemptive multitasking, BSD system services, and a full toolset. In addition, Mac OS X implements many POSIX APIs, which gives you access to a number of powerful UNIX tools and APIs and allows you to call supported POSIX routines from the BSD, Carbon, and Cocoa application environments.

Layered on top of its Darwin foundation, Mac OS X includes a visual interface that users see and use every day. This includes both the elegant Aqua user interface and the Finder, the primary application through which users find and manage directories, applications, and documents.

The Mac OS X file system architecture provides enhanced behavior that builds on its UNIX foundation. File access is governed by the traditional UNIX owner/group/other permissions system. In addition, the file system integrity and security is enhanced through the use of multiple file-system domains, which UNIX groups use to control user permissions on the files based on the domain to which they belong. Furthermore, the Carbon and Cocoa APIs offer powerful file system behavior that you can incorporate in your ported application. For example, you can include the use of aliases to find files when their location has changed, standard file open and save dialogs, and the traditional Mac OS X directory structure that is multiply rooted from individual volumes instead of singly rooted from the root volume.

To speed up your development process, Apple provides the Xcode Tools suite to prototype, compile, debug, and optimize your software. The Xcode application provides a powerful user interface to many industry standard and open source tools, including the GNU Compiler Collection (GCC), javac, jikes, and the GNU Debugger (GDB). Xcode contains templates for creating applications, frameworks, libraries, plug-ins, command-line tools, and Java applications and applets, and supports both Cocoa and Carbon development using C, C++, Objective-C, and Java.

Two of the most important programs in Xcode Tools are Interface Builder, for creating the user interface, and Xcode, for writing, compiling, and debugging your application. Interface Builder shows you exactly where to place interface elements so that they conform to Apple's spacing and placement guidelines found in the Apple Human Interface Guidelines. Xcode creates a nib-based project with a single directory containing all the files associated with your project. This makes it easy for you to back up your project or move it to another location. Xcode also manages build rules and dependency checking, eliminating the need for creating and maintaining a makefile. Your application's executable code and resources are assembled into an application bundle that you can build and deploy immediately by dragging the bundle's single icon to the desired location.

Disk Copy packages your ported application and documentation into a simple disk image, compresses it, and distributes it. A compressed disk image preserves any resource forks, and allows drag-and-drop installation, license display, and even encryption of data. For more complex applications that require administrator privileges or more than a simple drag-and-drop installation, you can use PackageMaker to build installer packages.

Mac OS X supports multiple application environments for developing and porting your applications, including Cocoa, Carbon, Java, and BSD. Cocoa is the best choice when developing a new application; Carbon for porting a Windows-based application or one already implemented in C or C++; BSD for command-line tools and other UNIX programs; and Java for existing Java applications.

To make life easier for UNIX developers, Apple provides a complete X Window System implementation that is compatible, fast, and fully integrated with Mac OS X. X11 for Mac OS X includes a Quartz window manager so that you can provide Aqua title bars and buttons for X11 windows, including fully functional close, minimize to Dock, and maximize buttons. Mac OS X also supports OpenGL, Qt, Tcl/Tk, and a number of other traditional UNIX graphics technologies. If you need to port a command-line utility that uses GNU Autoconf to Mac OS X, the utility usually configures itself, requiring only a small amount of adjustment. Just run configure and make as you would on any other UNIX-based system.

Windows developers will notice similarities between the Carbon and Win32 APIs, which eases the task of porting a Windows-based application. The Carbon framework provides procedural interfaces to Mac OS X functionality. You need to set up a Carbon-based project and user interface using Xcode and Interface Builder, and write an event handler for each control and application-specific menu item in your code. You will also need to rework any application logic that is not ready for cross-platform use such as byte-swapping to maintain cross-platform file compatibility.

Because Java is already installed and configured to work on Mac OS X, Java applications become nearly indistinguishable from native applications. Using the Mac OS X—specific system properties, you can add native behavior with very little work on your part. For example, you can put Swing menus in the Mac OS X menu bar, display a window's resize control or grow box, and display your main windows with the textured Aqua window appearance.

In addition, AppleScript and Apple Events allow you to script actions in your Java applications so you can generate and handle basic events such as Print and Open, choose menu items, click buttons, enter text into text fields, and generally control the GUI of your Java applications. The Jar Bundler tool packages your Java program's files and resources into a single double-clickable file that makes it easy for users to install and uninstall it, simply by dragging the file onto the desktop or off into the Trash.

As a developer on Mac OS X, you have access to many of the development tools and environments that you have on other platforms, like Java, OpenGL, POSIX libraries, and the BSD TCP/IP stack, but you also have built-in benefits like the Cocoa object-oriented development environment, the Quartz PDF-based display system, the Aqua user interface, and a suite of world-class developer tools. By adding a native Mac OS X front end to your application, you can achieve a new deployment platform with minimal additional development effort, ensuring that your application behaves the way that Macintosh users expect.

If you are ready to begin learning about the APIs and tools available for Porting, go to Getting Started With Porting, for a guided introduction and learning path.

For news, updates and links to other ADC content related to Porting, return to the Porting topic page.

Posted: 2005-09-19