If you upgraded your iPhone SDK to the final version supporting iOS 4, you have noticed that everything older then SDK 3.2 vanished. After some research, I found out you can build with 4.0 SDK and still run on devices with earlier versions of the firmware.
If you want to be compatible with iPhone OS 3.x you still compile for SDK 4.0, but set the target settings to tell that yout iPhone app can run on 3.x (iPhone OS Deployment Target). If you did not use any iOS 4.0 specific APIs then your app will run smoothly on 3.x and 4.x… Read on to learn more.
If you go to the Project Info screen and click Build, you can choose what Base SDK to use (4.0) and then scroll down to iPhone OS Deployment Target version and set it to 3.1.3. However, you also have to go to the Targets section under Groups & Files (red bullseye) select your target, get the Info build page, and set your iPhone OS Deployment Target there too.
Once that’s done, you should be able to test it with a device running iOS 3.x.
- Set your Deployment Target to the earliest version you want to be able to run with, ie: 3.0.
- You set your Base SDK to the latest version that you are compiling with, ie: 4.0. This way you can reference the newer definitions and symbols in your code.
- Weak link to the libraries/frameworks with symbols that are only available in the newer iOS. This is so your app will run on a device that doesn’t have the newer symbols.
- You must check to see that a newer method is available before calling it. You have to make sure not to call a method that is 4.0 only when your app is on a 3.x device.
- You will have to handle working on older versions by either using older methods or not supporting particular features that need newer SDK support.