< Previous PageNext Page > Hide TOC

About Bundles

The problem of managing code and related resources is not a new one and different operating systems have taken different approaches. In the past, resources have been compiled into the executable file, compiled into resource forks, and installed in known locations, among other techniques. The problem with many of these techniques is that they tend to be more fragile and in some cases complicate the process of updating the code and resources.

Bundles provide an elegant solution to the problem of grouping related code and resources together. A bundle is a hierarchical directory structure containing executable code and resources geared for a specific purpose. Applications, frameworks, and plug-ins can all be implemented as bundles in Mac OS X, and in fact, bundles are the preferred delivery mechanism for all of these software types. Developers can also use bundles for other purposes, including the implementation of custom document types.

Important: It is important to remember the distinction between what is a bundle and what is a package. The term bundle indicates a directory with a specific hierarchical structure, whereas the term package indicates a directory that is treated as an opaque entity by the Finder. Most bundles (including applications and plug-ins) are also packages. Some bundles, such as frameworks, are not packages, however.

Contents:

Advantages of Using Bundles
Types of Bundles
Programmatic Support for Bundles


Advantages of Using Bundles

Bundles provide significant advantages over other application packaging schemes available on Mac OS X.

Types of Bundles

The type of a bundle determines its internal directory structure and the location of key resources within that structure. Mac OS X supports two basic bundle types: modern and versioned. The modern bundle type is the one most commonly found on the system and is used to implement applications, plug-ins, and most other executables. The versioned bundle type is used almost exclusively to implement frameworks and umbrella frameworks.

For information about the structure of a modern bundle, see “Anatomy of a Modern Bundle.” For information about the structure of versioned bundles, see “Anatomy of Framework Bundles” in Framework Programming Guide.

Programmatic Support for Bundles

Programs that refer to bundles, or are themselves bundled, can take advantage of interfaces in Core Foundation and Cocoa to access the contents of a bundle. Using these interfaces you can find bundle resources, get information about the bundle’s configuration, and load executable code. Cocoa programs use an NSBundle object to manage bundle information. Most other programs use the CFBundle object and C-based functions that are part of Core Foundation.

Note: Unlike many other Core Foundation and Cocoa types, CFBundle and NSBundle are not toll-free bridged data types and cannot be used interchangeably. However, you can extract the bundle path information from either object and use it to create the other.



< Previous PageNext Page > Hide TOC


© 2003, 2005 Apple Computer, Inc. All Rights Reserved. (Last updated: 2005-11-09)


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.