About Information Property List Files
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 OS X 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.
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
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 Property List Editor Help.
For a list of the recommended keys you should include in a typical app, see “Recommended Info.plist Keys.”
Localizing Property List Values
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
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:
<string>Copyright ¬© 1995-2009, Apple Inc.,All Rights Reserved.
The French localization for TextEdit then includes the following strings in the
InfoPlist.strings file of its
CFBundleDisplayName = "TextEdit";
NSHumanReadableCopyright = "Copyright © 1995-2009 Apple Inc.\nTous droits réservés.";
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 Programming Topics.
Creating Device-Specific Keys
In iOS 3.2 and later, apps can designate keys in the
Info.plist file as being applicable only to specific types of devices. To create a device-specific key, you combine the key name with some special qualifiers using the following pattern:
In this pattern, the key_root portion represents the original name of the key. The <platform> and <device> portions are both optional endings that you can use to apply keys to specific platforms or devices. For the platform key, you can specify a value of
macos depending on the platform you are targeting.
To apply a key to a specific device, 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.
When specifying keys, it is recommended that you always include a key without any device modifiers so that you have a reasonable default value. You can then add versions of the key with device-specific overrides, as needed, to customize the value for a specific device. When searching for a key in your app’s
Info.plist file, the system chooses the key that is most specific to the current device first. If it does not find a device-specific key, it looks for one without any device modifiers. Thus, having an unmodified key means that there is always a default value for the given key. For example, to specify a portrait launch orientation for iPhone and iPod touch devices and a landscape-right launch orientation for iPad, you should specify the corresponding keys in your
OS X and iOS ignore any custom keys you include in an Info.plist file. If you want to include app-specific configuration information in your
Info.plist file, you may do so freely as long as your key names do not conflict with the ones Apple uses. When defining custom key names, it is advised that you prefix them with a unique prefix such as your app’s bundle ID or your company’s domain name.
Recommended Info.plist Keys
When creating an information property list file, there are several keys that 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
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:
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:
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
For more information about localizing information property list keys, see “Localizing Property List Values.”
© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)