A bundle is a directory in the file system that groups related resources together in one place. Applications, frameworks, and plug-ins are all examples of bundles. Programs can also use document bundles instead of flat files to save complex content.
Many bundles are also packages, that is, they are presented to the user as opaque files rather than as directories. This opaqueness has advantages for both users and developers. For users, it simplifies the user’s interaction with applications and other bundles and makes it harder to delete critical resources accidentally. For developers, it simplifies the software distribution process.
Both Cocoa and Core Foundation provide API for accessing the contents of a bundle. For more information on accessing bundles from Cocoa, see the NSBundle
class documentation. For information on accessing bundles from Core Foundation, see the CFBundle
reference.
For information about framework bundles, see Framework Programming Guide.
This document includes the following articles:
“About Bundles” provides background information about Mac OS X bundles and why you should use them.
“Anatomy of a Modern Bundle” gives you a tour of a modern bundle and provides examples of how different parts of a bundle contribute to the overall directory hierarchy.
“Bundles and the Resource Manager” explains the bundle support for Resource Manager-style resources and includes an example of how to load these resources from your application.
“Searching for Bundle Resources” explains the search algorithm used by NSBundle
and CFBundle
to locate resources, which is helpful for developers who need to place those resources initially.
“Packages and the Finder” describes the behavior of the Finder as it pertains to bundles and packages.
“Document Packages” provides guidelines for creating your custom document types using a package instead of a file.
“Guidelines for Using Bundles” provides guidelines for when and how to use bundles.
“Creating Bundles” provides basic instructions on how to create a new bundle or convert an older NeXT bundle to the modern bundle structure.
“Locating and Opening Bundles” demonstrates how to find bundles on the system.
“Locating Resources Inside a Bundle” explains the interfaces used to find resources inside a bundle.
“Loading and Unloading Executable Code” demonstrates how to call functions and access classes defined in plug-ins and other loadable bundles.
“Getting Information From a Bundle” demonstrates how to retrieve information about the bundle itself, including its configuration data and directory paths.
“Working With Localized Strings” discusses the interfaces used to retrieve localized strings from a bundle and shows you how to write code in a way that makes it easier to find localizable strings.
© 2003, 2005 Apple Computer, Inc. All Rights Reserved. (Last updated: 2005-11-09)