Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

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 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 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 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, set the application-icon-filename property in the Currency Converter Info.plist file.

    1. In the Currency Converter project, locate the CFBundleIconFile key in the Info.plist file.

    2. Set the corresponding string element to APPL.

    3. Save the Info.plist file.

The Info.plist file should look like Listing 7-2. The highlighted line points out the last modification.

Listing 7-2  Specifying a custom application icon 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>APPL</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>© My Company, 2007</string>
</dict>
</plist>

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. This practice also lets you to take advantage of Mac OS X services, such as managed installations. Managed installations rely on application identifiers and version numbers to determine, for example, whether a user is trying to install an earlier version of an application over a newer one. As a result, the user is protected from unknowingly performing a potentially disruptive operation.

You benefit from managed installations because, when you create a delivery solution for your product, you don’t have to worry about the details of installing the product for the first time, upgrading to a newer version, or downgrading to an earlier version. Mac OS X handles the details for you.



< Previous PageNext Page > Hide TOC


Last updated: 2007-10-31




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice