This section shows how to specify Currency Converter’s identifier, release version number, and copyright text.
Important: To complete this task, you need to open this document’s companion archive, ObjCTutorial_companion.zip.
Currency Converter’s name property is set to the project name you entered in “Creating a Project in Xcode,” Currency Converter. Therefore, you don’t need to change the value of this property.
To set the the application-identifier, build-version-number, release-version-number, and copyright-text properties, follow these steps:
In the Currency Converter project window, select the Resources group in the Groups & Files list.
Remove the InfoPlist.strings file from the project (this file is used for internationalization, a subject outside the scope of this document):
In the detail view, select the InfoPlist.strings file.
Choose Edit > Delete.
In the dialog that appears, click Delete References.
In the detail view, double-click the Info.plist file. The file opens in an editor window.
Set the application identifier to com.mycompany.CurrencyConverter:
Locate the CFBundleIdentifier key in the file.
Set the string element under the CFBundleIdentifier key to com.mycompany.CurrencyConverter.
Set the build version number to 100
Locate the CFBundleVersion key in the file.
Set the corresponding string element to 100.
Set the release version number 1.0.0
When the CFBundleShortVersionString key is not defined in the Info.plist file, you must add it:
Place the cursor after the last key/value pair in the Info.plist file, just before the </dict> tag.
Press Return.
Enter the following lines:
<key>CFBundleShortVersionString</key> |
<string>1.0.0</string> |
Set the copyright text to © 2007, My Company:
Add the following key/value pair to the Info.plist file (press Option-G to produce the © character):
<key>NSHumanReadableCopyright</key> |
<string>© 2007, My Company</string> |
Save the Info.plist file.
Listing 7-1 shows how Currency Converter’s property list file might look after the changes. The highlighted lines have been either modified or added.
Listing 7-1 Specifying domain, version, and copyright information in the Currency Converter Info.plist file
<?xml version="1.0" encoding="UTF-8"?> |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
<plist version="1.0"> |
<dict> |
<key>CFBundleDevelopmentRegion</key> |
<string>English</string> |
<key>CFBundleExecutable</key> |
<string>${EXECUTABLE_NAME}</string> |
<key>CFBundleIconFile</key> |
<string></string> |
<key>CFBundleIdentifier</key> |
<string>com.mycompany.CurrencyConverter</string> |
<key>CFBundleInfoDictionaryVersion</key> |
<string>6.0</string> |
<key>CFBundleName</key> |
<string>${PRODUCT_NAME}</string> |
<key>CFBundlePackageType</key> |
<string>APPL</string> |
<key>CFBundleSignature</key> |
<string>????</string> |
<key>CFBundleVersion</key> |
<string>100</string> |
<key>NSMainNibFile</key> |
<string>MainMenu</string> |
<key>NSPrincipalClass</key> |
<string>NSApplication</string> |
<key>CFBundleShortVersionString</key> |
<string>1.0.0</string> |
<key>NSHumanReadableCopyright</key> |
<string>© 2007, My Company</string> |
</dict> |
</plist> |
To see how this affects your application:
Clean the project, and build and run the application.
Choose Currency Converter > About Currency Converter.
Notice how the name, version number, and copyright information you entered in the info.plist file are displayed correctly here.
Note: If the information, such as the copyright information, is not the same, your NSHumanReadableCopyright value may be different from the one you entered in the Info.plist file. This will occur if there is an extra file called InfoPlist.strings (English). This file is used for localization, that is, having different properties for an application based on the location it’s designed for. In this case, any key values set in the English localization file will override the values set in the Info.plist file when compiling the English version of the project. To fix this issue, you can either delete the InfoPlist.strings (English) file, or open the file and change the value just as in the Info.plist file.
Quit Currency Converter.
To see how application identifiers can be beneficial, execute the following command in a Terminal window:
> open -b com.mycompany.CurrencyConverter |
The open command locates and launches Currency Converter based on its application identifier. This command can also use the filenames of application bundles to locate and launch applications (the .app suffix is optional).
In the Dock, Control-click or click-and-hold the Currency Converter icon and choose Show In Finder from the shortcut menu, as shown in Figure 7-3.
The Finder opens a window shown in Figure 7-4, displaying the Currency Converter application bundle. Notice that the release version number (CFBundleShortVersionString) appears in the preview column (in column view) and in the Info window for the application bundle. The About Currency Converter window shows the application name (CFBundleName), build version number (CFBundleVersion) in parentheses, release version number, and copyright text (NSHumanReadableCopyright).
Quit Currency Converter.
Now the only essential application identification information left unspecified for Currency Converter is its icon.
Last updated: 2007-10-31