Application Icon TroublesAug 4, 2010 · 4 minute read · Comments
I have posted several times about updating the icon files for an application. First when building a universal app for the iPad and more recently when updating an app for the iPhone 4 retinal display. Apple introduced a new naming convention with iOS 4 to make it easier to handle high and low resolution versions of the same image file (thus we have Icon.png and [email protected]). They also introduced a convention for the CFBundleIconFiles key to avoid having to specify both variations of the file. Here is what the Apple Application Programming Guide says:
When specifying icon files using the CFBundleIconFiles key, it is best to omit the filename extensions of your image files. If you include a filename extension, you must explicitly add all of your image files (including any high-resolution variants) to the array. When you omit the filename extension, the system automatically detects high-resolution variants of your file using the base filename you provide.
This even seems to work at first when testing in the simulator or a device. The problem comes when you validate the built product or try to upload it with the Apple application loader. Unfortunately you are likely to be driven crazy by the following validation error:
Icon specified in the Info.plist CFBundleIconFile does not have an extension: Icon (-19006)
I have not seen any official confirmation from Apple but based on some comments from Apple employees in the development forums it would appear that this is actually a known problem with the application loader supplied with Xcode 3.2.3. For the time being I would recommend specifying the icon names with the extension to avoid this problem.
Test Application Icons
I got sufficiently frustrated with this situation to create a set of application icons covering all possible dimensions to make it possible to understand which icons are actually getting used. The icons are a simple black background with a white number in the middle indicating the size of the file. The icon files are named as follows:
- Icon.png (57 x 57)
- [email protected] (114 x 114)
- Icon-72.png (72 x 72)
- Icon-Small.png (29 x 29)
- [email protected] (58 x 58)
- Icon-Small-50.png (50x50)
If you want them you can download these with a sample application that I created to test out some common scenarios. The application does nothing - it is just the standard Xcode template for a view application. It contains three targets setup as follows:
iPhone 4 Only Application
This setup is for an application that will target only the iPhone running iOS 4 (no iPad or pre iOS 4 releases). It includes standard and high resolution icons for the iPhone 4 device.
- Target Name: Icon40
- Targeted Device Family: iPhone
- iPhone OS Deployment Target: iPhone OS 4.0
The Info.plist file does NOT have the CFBundleIconFile string key, instead it has the CFBundleIconFiles array key which contains two entries (Icon.png and [email protected]).
When run on a normal iPhone or iPod Touch device (running iOS 4) the home screen icon displayed should show “57”. When run on the high-resolution iPhone 4 the home screen icon should show “114”. In addition if you go the spotlight search page and search for Icon you should see the “29” image on the normal phone and “58” on the iPhone 4.
iPhone 4 and iPad 3.2 Application
This scenario adds the iPad and has the following basic target settings:
- Target Name: Icon32
- Targeted Device Family: iPhone/iPad
- iPhone OS Deployment Target: iPhone OS 3.2
The Info.plist file is similar to previous scenario with the addition of the Icon-72.png iPad icon to the CFBundleIconFiles array:
When running on iPhone devices (with iOS 4) it should perform as in the previous scenario. When run on the iPad the home screen icon should show “72” and the spotlight search page should show “50”.
iPhone 4, iPad 3.2 and iPhone 3.x Application
This setup if for all devices back to iPhone 3.x, the target settings are as follows:
- Target Name: Icon31
- Targeted Device Family: iPhone/iPad
- iPhone OS Deployment Target: iPhone OS 3.1
The Info.plist file contains the CFBundleIconFile key for 3.1 compatibility with the value Icon.png together with the CFBundleIconFiles key from the iPad example:
This should run with the older 3.x devices showing “57” on the home screen but with newer iPhone 4 devices showing 114 (and the iPad showing 72).