Mac App Bundle Info Plist

I occasionally need to help one of our customers get the bundle identifier for a given app, for some purpose with one of our apps. While the task isn't complicated—the value is stored in a file named Info.plist within each app bundle—it's not something that's necessarily easy to explain to someone who doesn't have a lot of Mac experience. STEP 2: Add bundle identifier to every Info.plist Yes. Every file that contains a Info.plist, must be updated. However, all that is necessary is to add your Bundle Identifier. Simply, search info.plist in your application’s folder, and copy-paste the Bundle Identifier row from your main Info.plist file.

An information property list file is a structured text file that contains essential configuration information for a bundled executable. The file itself is typically encoded using the Unicode UTF-8 encoding and the contents are structured using XML. The root XML node is a dictionary, whose contents are a set of keys and values describing different aspects of the bundle. The system uses these keys and values to obtain information about your app and how it is configured. As a result, all bundled executables (plug-ins, frameworks, and apps) are expected to have an information property list file.

By convention, the name of an information property list file is Info.plist. This name of this file is case sensitive and must have an initial capital letter I. In iOS apps, this file resides in the top-level of the bundle directory. In macOS bundles, this file resides in the bundle’s Contents directory. Xcode typically creates this file for you automatically when you create a project of an appropriate type.

Important: In the sections that follow, pay attention to the capitalization of files and directories that reside inside a bundle. The NSBundle class and Core Foundation bundle functions consider case when searching for resources inside a bundle directory. Case mismatches could prevent you from finding your resources at runtime.

Creating and Editing an Information Property List File

The simplest way to create an information property list file is to let Xcode create it for you. Each new bundle-based project that you create in Xcode comes with a file named <project>-Info.plist, where <project> is the name of the project. At build time, this file is used to generate the Info.plist file that is then included in the resulting bundle.

To edit the contents of your information property list file, select the <project>-Info.plist file in your Xcode project to display the property list editor. Figure 1 shows the editor for the information property list file of a new Cocoa app project. The file created by Xcode comes preconfigured with keys that every information property list should have.

To edit the value for a specify key, double-click the value in the Xcode property list editor to select it, then type a new value. Most values are specified as strings but Xcode also supports several other scalar types. You can also specify complex types such as an array or dictionary. The property list editor displays an appropriate interface for editing each type. To change the type of a given value, make sure the value is not selected and Control-click it to display its contextual menu. From the Value Type submenu, select the type you want to use for the value.

Because information property lists are usually just text files, you can also edit them using any text editor that supports the UTF-8 file encoding. Because they are XML files, however, editing property list files manually is generally discouraged.

Adding Keys to an Information Property List File

Although the Info.plist file provided by Xcode contains the most critical keys required by the system, most apps should typically specify several additional keys. Many subsystems and system apps use the Info.plist file to gather information about your app. For example, when the user chooses File > Get Info for your app, the Finder displays information from many of these keys in the resulting information window.

You add keys to your app’s Info.plist using the Xcode property list editor. For information about how to use this editor, see “Edit property lists.”

Important: The property list editor in Xcode displays human-readable strings (instead of the actual key name) for many keys by default. To display the actual key names as they appear in the Info.plist file, Control-click any of the keys in the editor window and enable the Show Raw Keys/Values item in the contextual menu.

For a list of the recommended keys you should include in a typical app, see Recommended Info.plist Keys.

Localizing Property List Values

Editor

The values for many keys in an information property list file are human-readable strings that are displayed to the user by the Finder or your own app. When you localize your app, you should be sure to localize the values for these strings in addition to the rest of your app’s content.

Localized values are not stored in the Info.plist file itself. Instead, you store the values for a particular localization in a strings file with the name InfoPlist.strings. You place this file in the same language-specific project directory that you use to store other resources for the same localization. The contents of the InfoPlist.strings file are the individual keys you want localized and the appropriately translated value. The routines that look up key values in the Info.plist file take the user’s language preferences into account and return the localized version of the key (from the appropriate InfoPlist.strings file) when one exists. If a localized version of a key does not exist, the routines return the value stored in the Info.plist file.

For example, the TextEdit app has several keys that are displayed in the Finder and thus should be localized. Suppose your information property list file defines the following keys:

The French localization for TextEdit then includes the following strings in the InfoPlist.strings file of its Contents/Resources/French.lproj directory:

For more information about the placement of InfoPlist.strings files in your bundle, see Bundle Programming Guide. For information about creating strings files, see Resource Programming Guide. For additional information about the localization process, see Internationalization and Localization Guide.

Creating Platform- and Device-Specific Keys

You can designate a key in an Info.plist file as applying to a specific platform, a specific device type, or both. To create a platform- or device-specific key variant, combine a root key name with one or two qualifiers, using the following pattern:

key_root-<platform>~<device>

In this pattern, the key_root portion represents the original name of the key, as you find it in this document. The <platform> and <device> portions are optional and restrict the key’s applicability to a specific platform or device type. Notice that if you employ a platform qualifier, connect it with a hyphen (-), and if you employ a device qualifier, connect it with a tilde (~).

Use of a device qualifier is much more common than is use of a platform qualifier.

For a device qualifier, you can use one of the following values:

  • iphone The key applies to iPhone devices only

  • ipod The key applies to iPod touch devices only

  • ipad The key applies to iPad devices only

For a platform qualifier, you can specify a value of iphoneos or macos depending on which of these two platforms you are targeting.

When specifying a key variant, do so in addition to employing a corresponding key without any qualifiers, thereby ensuring you provide a reasonable default value. When the system searches for a key in your app’s Info.plist file, it chooses the key that is most specific to the current device and platform. If it does not find a qualified key, it looks for one without qualifiers. For example, to specify support for all device orientations on iPad, and three orientations for iPhone, the Xcode templates specify the corresponding keys in an app’s Info.plist file:

Custom Keys

iOS and macOS ignore custom keys you include in an Info.plist file. If you want to include app-specific configuration information in your Info.plist file, you can do so freely as long as your key names do not conflict with the ones Apple uses. When defining custom key names, prefix them with a unique prefix, such as your app’s bundle ID or your company’s domain name, to prevent conflicts.

Recommended Info.plist Keys

Mac Plist

Each of the Xcode application templates includes an Info.plist file, but you can also construct one from scratch. When creating an information property list file, there are several keys you should always include. These keys are almost always accessed by the system and providing them ensures that the system has the information it needs to work with your app effectively.

Recommended Keys for iOS Apps

Plist Files Mac

It is recommended that an iOS app include the following keys in its information property list file. Most are set by Xcode automatically when you create your project.

In addition to these keys, there are several that are commonly included:

  • UIRequiredDeviceCapabilities (required)

For descriptions of these keys, see the other chapters of this book.

Recommended Keys for Cocoa Apps

It is recommended that a Cocoa app include the following keys in its information property list file. Most are set by Xcode automatically when you create your project but some may need to be added.

These keys identify your app to the system and provide some basic information about the services it provides. Cocoa apps should also include the following keys to identify key resources in the bundle:

Note: If you are building a Cocoa app using an Xcode template, the NSMainNibFile and NSPrincipalClass keys are typically already set in the template project.

For descriptions of these keys, see the other chapters of this book.

Commonly Localized Keys

In addition to the recommended keys, there are several keys that should be localized and placed in your language-specific InfoPlist.strings files:

For more information about localizing information property list keys, see Localizing Property List Values.



Copyright © 2018 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2018-06-04

To provide a better experience for users, iOS and macOS rely on the presence of special metadata in each app or bundle. This metadata is used in many different ways. Some of it is displayed to the user, some of it is used internally by the system to identify your app and the document types it supports, and some of it is used by the system frameworks to facilitate the launch of apps. The way an app provides its metadata to the system is through the use of a special file called an information property list file, or Info.plist for short.

A property list is a way to structure arbitrary data that the system can access at runtime. An information property list is a specialized type of property list that contains configuration data for a bundle. The keys and values in the file describe the various behaviors and configuration options you want applied to your bundle. An Xcode project template typically specifies an information property list file with an initial set of keys and appropriate default values. You can edit the file to change or add keys and values, as appropriate for your project.

At a Glance

This document describes the keys and corresponding values that you can include in an information property list file. This document also includes an overview of information property list files to help you understand their importance and to provide tips on how to configure them.

The Info.plist File Configures Your App

Every app and plug-in uses an Info.plist file to store configuration data in a place where the system can easily access it. macOS and iOS use Info.plist files to determine what icon to display for a bundle, what document types an app supports, and many other behaviors that have an impact outside the bundle itself.

Relevant chapter:About Information Property List Files

Core Foundation Keys Describe Common Behavior

There are many keys that you always specify, regardless of the type of bundle you are creating. Those keys start with a CF prefix and are known as the Core Foundation keys. Xcode includes the most important keys in your Info.plist automatically but there are others you must add manually.

Launch Services Keys Describe Launch-Time Behavior

Launch Services provides support for launching apps. To do this, though, it needs to know information about how your app wants to be launched. The Launch Services keys describe the way your app prefers to be launched.

Relevant chapter:Launch Services Keys

Cocoa Keys Describe Behavior for Cocoa and Cocoa Touch Apps

The Cocoa and Cocoa Touch frameworks use keys to identify high-level information such as your app’s main nib file and principal class. The Cocoa keys describe those and other keys that affect how the Cocoa and Cocoa Touch frameworks initialize and run your app.

macOS Keys Describe Behavior for macOS Apps

Some macOS frameworks use keys to modify their basic behavior. Developers of Mac apps might include these keys during testing or to modify certain aspects of your app’s behavior.

Relevant chapter:macOS Keys

iOS Keys Describe Behavior for iOS Apps

Info

An iOS app communicates a lot of information to the system using Info.plist keys. Xcode supplies a standard Info.plist with the most important keys but most apps need to augment the standard file with additional keys describing everything from the app’s initial orientation to whether it supports file sharing.

watchOS Keys Describe Behavior for Watch Apps

Use the Info.plist keys associated with the watchOS frameworks to configure your Watch apps and WatchKit extensions.

Relevant chapter:watchOS Keys

App Extension Keys Describe Behavior for iOS and macOS App Extensions

App extensions let you make custom behaviors available in other apps and in system facilities such as notification center. Xcode’s app extension templates each supply a standard Info.plist file with the most important keys, but you can specify additional keys that describe custom behavior for your app extensions.

See Also

For an introduction to property lists, including how they are structured and how you use them in general, see Property List Programming Guide.

Some Info.plist keys use Uniform Type Identifiers (UTIs) to refer to data of different types. For an introduction to UTIs and how they are specified, see Uniform Type Identifiers Overview.

Kernel extension developers need to use certain Info.plist keys in different ways than app developers do, and also need some kernel-extension-specific keys that have no use in app development. If you are developing a kernel extension, refer to the chapter Info.plist Properties for Kernel Extensions in Kernel Extension Programming Topics.



Copyright © 2018 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2018-06-04