Since many iPhone and iPod Touch users have not upgraded to the iPhone OS 3.0, it makes a lot of sense to enable backward compatibility on applications. But if you want to leverage the latest 3.0 features, you would have to put some extra effort to ensure full backward compatibility.

And if you are also integrating 3rd party libraries (analytics, ad networks etc.), you would have to ensure those also are backward compatible.

Q: How can I ensure that my application works on all iPhone OS versions from OS 2.0 to the latest 3.x version? And I do need to use some 3.0 features like push notifications or the Map Kit functions.

  1. Choose the Base SDK as iPhone Device 3.0. You can do this by right click on project name->Get Info. Then on the General tab, set the “Base SDK for All Configurations”to “iPhone Device 3.0″.
  2. Choose your deployment to be the lowest version you want to support. You can do this by right click on project name->Get Info. Then on the Biold tab, select “All Configurations” for Configuration so that this change is applied to all you configurations. Then look for the “iPhone OS Deployment Target” property under the “Deployment” section. Set that to the correct iPhone OS version. In my case I set it to “iPhone OS 2.0″.
  3. In your code wherever you use any APIs available only in versions later than your deployment target, use them conditionally after checking if they are available. This can be done for both classes and selectors.

Apple’s documentation describes this in further detail. Here is an image from the documentation that describes how the compatibility works based on the configuration:

When using 3rd party APIs and linking to dylib libraries, there might be further problems if the versions are not compatible. When trying ot integrate AdWhirl, we got an error:

Dyld Error Message:
  Library not loaded: /usr/lib/libxml2.2.dylib
  Referenced from: ......
  Reason: Incompatible library version: xxxxx requires version 10.0.0 or later, but libxml2.2.dylib provides version 9.0.0

This happens because iPhone OS version 2.x  and 3.xuse different versions of the library. The simplest way to fix this is to make the linking for the library weak. This can be done by right click on your application under “Targets” and select Get Info. Then on the General tab, under the linked libraries, locate this library and change the linking type from “Required” to “Weak”