Friday, October 30, 2009

Section 10.3.  Application Bundles










10.3. Application Bundles


Applications are the most common type of bundle (see Figure 10.3). An application directory has a name with the suffix .app. The .app directory is a file package; even though it is a directory, the Finder treats it as a single entity. This allows the author of the application to place auxiliary files for the application in a known placeinside the application bundle itselfwith little fear that such files will be misplaced or deleted.



Figure 10.3. The structure of a typical application bundle. The executable file is at Contents/MacOS/Application. The application's human interface for English-speaking users is specified in Contents/Resources/English.lproj/MainMenu.nib; presumably, a French version of MainMenu.nib is inside Contents/Resources/FR.lproj. The custom image for a button, ButtonImage.tif, is common to all languages and therefore appears directly in the Resources directory.







The Contents directory of an application bundle contains


  • Info.plist, an XML property list file that describes such application details as the principal class, the document types handled, and the application version. More on this file in Section 10.4.

  • Resources, a directory containing the application icon file, images, sounds, human interface (UI) layouts, and other parameterized content for the application.

    This directory may be further organized into subdirectories, according to your convenience. In addition, there may be localization subdirectories, which have the .lproj suffix. When an application seeks a resource, the Cocoa or Core Foundation bundle managers will look first in the .lproj directory that corresponds to the current language and locale.

  • MacOS, a directory containing the executable binary for the application, along with any other executables used by the application. A bundle may be fat, containing executable directories for all the supported target architectures, but for now, only MacOS and MacOSClassic (for Mac OS 9) are supported. (This fat bundle is to be distinguished from fator as Apple marketing prefers, universalbinaries, single Mach-O executable files that include code compiled for more than one processor. An application that runs natively on 32-bit PowerPC, 64-bit PowerPC, and Intel processors would have a single executable file in the MacOS folder.)

  • Frameworks, a directory of frameworks that are themselves versioned bundles, containing a dynamic library, resources needed by the library, and header files needed by users of the library. An application typically includes a framework because it links to the framework's library.


Individual resource files can be restricted to a target architecture by appending a hyphen and the architecture name to the resource's base name. This way, an application may ask for picture.tif, and the Core Foundation bundle manager will return picture-macos.tif or picture-macosclassic.tif, as appropriate.












No comments:

Post a Comment