Mac OS X Reference Library Apple Developer
Search

Configuring Your Application

Now that you have your very own functional application, it’s time to give it individual properties instead of the default properties. In this chapter, you learn about the Info.plist file, which is where you can change properties that govern your application’s attributes. This chapter also describes the essential identification properties required of Mac OS X applications. It walks you through the process of configuring these properties in Currency Converter. You learn what changing these various properties does when viewing information about the application. Finally, you learn how to give an application its own icon to set it apart from other applications.

The Info.plist File

Mac OS X applications contain information to help distinguish them from one another. This information includes the application’s primary and secondary version numbers, and the icon that the Finder and the Dock use to represent it. The file that stores these details is known as the information property list file (named Info.plist). This property list file is stored with the executable files and resources that make up an application, known as an application bundle.

Note: A bundle is a directory that groups files in a structured hierarchy. To make it easy for users to manipulate bundles, bundles can be represented as files instead of folders in the Finder; these bundles are known as packages. An application bundle stores the executable files and resources that make up an application. Although it‚Äôs more correct to refer to application bundles as application packages because they‚Äôre always shown to users as single files in the Finder, this chapter adopts the term application bundle instead of application package. For more information on bundles and packages, see Bundle Programming Guide.

Basic Project Attributes

There are several essential properties that identify applications to users and to Mac OS X: application identifier, build version number, release version number, copyright notice, application name, and application-icon filename.

For further details on these and other application properties, see Runtime Configuration Guidelines.

Specify the Identifier, Version, and Copyright Information

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.

First, remove the InfoPlist.strings file from the project. This file is used for internationalization, a subject outside the scope of this tutorial.

  1. In the Currency Converter project window, select the Resources group in the Groups & Files list.

  2. In the detail view, select the InfoPlist.strings file.

  3. Choose Edit > Delete.

  4. In the dialog that appears, click Also Move to Trash.

To set the application-identifier and build-version-number, follow these steps:

  1. Open the Targets group in the project window and select the Currency Converter target.

  2. Choose File > Get Info to view the Target Info.

  3. Click the Properties tab to display the target’s properties.

  4. Enter com.mycompany.CurrencyConverter in the Identifier field to set the application identifier.

  5. Enter 100 in the Build field to set the build-version-number to 100.

The release-version-number and copyright-text properties aren’t exposed in the Properties tab. You can edit them, and other attributes stored in the Info.plist file, by opening the Info.plist file and editing it directly.

  1. Click the Open Info.plist as File button at the bottom of the Properties tab.

    The Info.plist file is displayed in an editor, showing a list of keys on the left side and their associated values on the right side.

  2. Set the release version number to 1.0.0

    Find the “Bundle version string, short” entry in the editor and change its value to “1.0.0”.

  3. Set the copyright text to © 2009, My Company:

    1. Select a line of the Info.plist file and click the plus button at the right end of the line.

    2. Choose “Copyright (human-readable)” from the list of keys.

    3. Double-click the value cell on the right side of the table and enter the text “© 2009, My Company”.

  4. Save the Info.plist file.

To see how this affects your application:

  1. Clean the project, and build and run the application.

  2. 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.

  3. Quit Currency Converter.

  4. 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).

  5. 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.

    Figure 7-3  Locating the application bundle from the Dock

    Locating the application bundle from the Dock

    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).

    Figure 7-4  Application properties as seen by the user

    Application properties as seen by the user
  6. Quit Currency Converter.

Now the only essential application identification information left unspecified for Currency Converter is its icon.

Create an Icon File

When you create a Cocoa application without specifying an icon for it, the Finder and the Dock assign it the generic application icon, as shown in Figure 7-4. To make your applications more appealing to their users and to differentiate them from other applications, you should give your applications distinctive icons. As a result, your applications stand out from other applications in Finder windows and in the Dock. This section describes the process of creating an icon file using Icon Composer and configuring Currency Converter to use the icon file. To do this, you must have downloaded the companion file provided with this document.

Note: Before doing this, make sure you have downloaded the companion archive (ObjCTutorial_companion.zip). The archive contains the icon image you will be using for this section.

To create the icon file for Currency Converter:

  1. Launch Icon Composer, located in /Developer/Applications/Utilities. Icon Composer displays an empty icon file editor window.

  2. In the Finder, navigate to the ObjCTutorial_companion/application_icon_images directory. This directory contains the image file that depicts the Currency Converter application icon.

  3. Add the image file to the icon file.

    1. Drag c_conv512.png from the Finder window to the Large Image image well in the icon file editor, as shown in Figure 7-5.

      Figure 7-5  Dragging c_conv512.png to the icon file editor

      Dragging c_conv512.png to the icon file editorDragging c_conv512.png to the icon file editor
    2. A dialog asks if you would like to copy the image to other sizes. Choose “Copy to all smaller sizes” and press Import. This automatically scales the 512 x 512 image to the smaller sizes.

    3. The hit masks for all sizes are automatically extracted. Hit masks are a bitmapping of the locations in which the image will respond when it is clicked.

    4. The icon file editor should look like Figure 7-6.

      Figure 7-6  Icon file editor with icon images and icon masks at several resolutions

      Icon file editor with icon images and icon masks at several resolutionsIcon file editor with icon images and icon masks at several resolutions
  4. Save the icon file.

    1. Choose File > Save As.

    2. In the Save dialog, navigate to the Currency Converter project directory.

    3. In the Save As text field, enter APPL.icns.

    4. Click Save.

  5. Quit Icon Composer.

Although the Currency Converter project directory contains the APPL.icns file, you still need to add it to the project.

To add the icon to the project:

  1. In the Currency Converter project window, select the Resources group in the Groups & Files list.

  2. Choose Project > Add to Project.

  3. In the dialog that appears, select the APPL.icns file in the Currency Converter project directory, and click Add, as shown in Figure 7-7.

    Figure 7-7  Selecting the icon file to add to the Currency Converter project

    Selecting the icon file to add to the Currency Converter projectSelecting the icon file to add to the Currency Converter project
  4. In the dialog that appears next, shown in Figure 7-8, click Add.

    Figure 7-8  Specifying project file-addition options

    Specifying project file-addition options
  5. Finally, specify the name of the icon file in the Icon File field of the target properties.

To see the icon in your project:

  1. Quit Currency Converter if you have not done so already.

  2. Choose Build > Clean.

  3. Click “Build and Go” to build and run the application.

  4. Currency Converter now has a distinguishing icon, shown in Figure 7-9.

    Figure 7-9  Currency Converter sporting an elegant icon

    Currency Converter sporting an elegant icon

Configuring your applications appropriately is essential for providing a good experience to your customers.

What’s Next?

Now that your project is complete, you may want to learn about what separates Cocoa from other frameworks. You probably noticed how much you can do with the application you built without programming any of those features. In the next chapter, you learn about many of the features Cocoa supplies and how to take advantage of them.




Last updated: 2009-08-03

Did this document help you? Yes It's good, but... Not helpful...