Bundles

Author: Mark Szymczyk
Last Update: May 9, 2007

This article provides an introduction to Mac OS X application bundles, showing you how to create an application bundle, add files and folders to the bundle, and retrieve files from the bundle.

What Are Bundles and Packages?

A bundle is a directory. That’s all it is: a directory. A package wraps a bundle so the bundle looks like a single file instead of a directory. The most common bundle is an application bundle, which contains an executable file and the external files the application uses. A game’s external files include graphics files, sound files, and data files like levels.

Most Mac OS X GUI applications are application bundles. Application bundles are packages, which provides a major benefit for software developers. Packages appear to the user as a single file so he or she can’t accidentally delete or rename the external files your application needs to run.

Application Bundle Organization

Because most Mac OS X applications are application bundles, there are many examples for you to look at. To examine an application bundle, select an application from the Finder and control-click. A contextual menu will open. Choose Show Package Contents.

When you examine an application bundle, the top folder is named Contents, which holds the contents of the bundle. What lies underneath the Contents folder depends on the application, but there will be a minimum of four items.

  • A MacOS folder that contains the executable file.
  • A Resources folder that holds the external files. Your application will store its files here.
  • A PkgInfo file, which tells you the type of bundle it is and the bundle’s creator code. The creator code links your application to its document files so that your application will open when the user double-clicks a document file in the Finder.
  • An info.plist file that provides various pieces of information about the bundle, such as its version number and the name of the executable file.

If you look inside an application’s Resources folder, you can see what spoken languages the application supports. There will be a folder with the extension .lproj for each language the application supports.

More complicated applications pack more folders into their bundles. Xcode has a Plugins folder that contains Xcode’s plugins. iTunes has a Frameworks folder that contains the code frameworks iTunes uses.

Next (Creating Bundles)