iPhone Development 101

iPhone 101

Code Tips




Mailing ListTwitter


iPhone Development 101: Distribution:
Checklist for Updating an App to iOS4

Here's a checklist of what to focus on to make your app look good and work well on iOS4.

  1. Create High-Res Icons for Retina Displays (optional)
  2. Create High-Res Images (optional)
  3. Update for Multitasking (important)
  4. Ensure Backward Compatibility (important)

1. Create High-Res Icons for Retina Displays

Prior to iOS4, iPhone app icons were 57x57-pixel PNG files. For the iPhone 4's retina display, you need one that's double that size: 114x114 pixels. If you want the icon to look good on the iPad, you should also include a 72x72 pixel icon.

Various icon sizes for iOS

To add the icons to your Xcode project, add them like you would any other image: Project menu -> Add To Project.

Then you'll need to modify the app's Info.plist file with the list of icons. In the XCode plist editor, add a new plist item called "Icons" show me. Be sure to also set the Icon property to your 57x57 sized icon; that way it'll work with older versions of iOS.

You can also add the icon info as raw XML. Right click on the Info.plist file name, select "Open As", then select "Source Code File" to view the raw XML. Show me Then add "CFBundleIconFiles" to the file:


(Note: you don't have to name the icons with these specific filenames. You can use any name for the icon image files, just be sure that the entries in Info.plist correspond to the filenames you used.)

There are some additional icon sizes you can provide (for Spotlight searches and the Settings screen), but those aren't required. You can read more about the various icon sizes here.

• Apple Documentation: iOS Development Guide: Configuring Applications (Editing plist Files)

2. Create High-Res Images (for Retina Displays)

This is optional, but if you want your app's graphics to look sharp on the new retina display, you'll need to create high-res versions of your app's images. These are double the size (width x height) of the original images, and are named imageName@2x.png.

For example, if you have a 320 x 480 image called background.png, create a 640 x 960 version called background@2x.png and add it to the project. On devices with the new retina display, the app will automatically use the correct image for the current device, with no code changes required.

This does mean that you'll need to create TWO sets of graphics; one for the older low-res devices, and a 2x set for high-res devices.

• Apple Documentation: Supporting High Resolution Screens

3. Update For Multitasking

Apps compiled for iOS4 must support multitasking. This means that when the user presses the "home" button on the phone, your app doesn't quit; instead it moves into the background. If you're running a looping timer, you must pause it; if your app needs to save data, you should do it in the applicationWillResignActive method (instead of the applicationWillTerminate method). This ensures that your data is saved if the OS kills your app while it's still in the background.

These methods are called when the app enters the background. (These methods should be implemented in your app delegate class.) You can also have other objects listen for the specific notifications.

- (void)applicationWillResignActive:(UIApplication *)application {
    // Called prior to entering the background. This is a good place to save your data.    
    // After calling this method, the application also posts a UIApplicationWillResignActiveNotification notification to give interested objects a chance to respond to the transition.

    NSLog(@"app will resign active");
    // [self saveData];

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Called when the user presses the home button to "quit" the application. (The app is suspended.) Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // The application also posts a UIApplicationDidEnterBackgroundNotification notification around the same time it calls this method to give interested objects a chance to respond to the transition.
    NSLog(@"app did enter background");
    // [self stopTimers];

Keep in mind that applicationWillResignActive is also called whenever the app is interrupted by the OS, such as when a call comes in, or a SMS or push notification pops up. See the iOS Programming Guide for details.

These methods are called when the app returns from the background (i.e, the user presses the app icon to launch the app again):

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as the app resumes. Here you can undo many of the changes made on entering the background - restart timers, resume networking, etc.

    // The application also posts a UIApplicationWillEnterForegroundNotification notification shortly before calling this method to give interested objects a chance to respond to the transition.
    NSLog(@"app will enter foreground");

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // After calling this method, the application also posts a UIApplicationDidBecomeActiveNotification notification to give interested objects a chance to respond to the transition.    
    NSLog(@"app did become active");

Note that none of these methods actually enable your app to run code in the background. iOS4 supports a limited set of tasks your app can run in the background. View the Apple documentation for more details:

4. Ensure Backwards Compatibility

Be sure to build for iOS 3.1.3 if you want to support older devices! This is easy to miss, and you could accidentally end up building your app for iOS4 only.

To target older devices, get info on your target, then look in the Build tab show me. Set Architectures to "Standard (armv6 armv7)", Base SDK to "Latest", and then scroll down a ways and set the iOS Deployment Target to iOS 3.1.3 (or whatever version you want to support). show me Devices running iOS versions older than this will not be able to run your app.