Testing universal app for iPhone

In my recent posts on creating a Universal version of an app that will work on both the iPhone and iPad I neglected to mention one small caveat when it comes to testing the app.

You cannot currently test the iPhone version of a universal app in the iPhone Simulator. You must test it on an actual iPhone or iPod Touch device.

There is no problem to test the iPad version of your app in the simulator but when you want to test the iPhone version of the app you must attach a physical device. You can then build and run on the device and the iPhone version of the app will be executed.

To understand why this limitation exists remember that when you build a universal app you build it with a base SDK of iPhone OS 3.2 but with a target iPhone OS version of 3.1.x or earlier. This means that the only option you have when building is to specify OS 3.2. If you try to build for OS 3.1.3 for example you will get compiler errors and warnings:

warning: implicit declaration of function 'UI_USER_INTERFACE_IDIOM'  error:
'UIUserInterfaceIdiomPad' undeclared (first use in this function)

This should not really be a surprise since symbols such as UI_USER_INTERFACE_IDIOM only exist in the 3.2 release of the SDK.