2
votes

I currently have an app on the App Store that was built with version 2.2.1, i.e. where the Base SDK and the Deployment Target were both set to 2.2.1. That app runs fine. Since then I've upgraded my version of XCode to 3.1.3 and I'm working on an update to my app with the Base SDK set to 3.0 and the Deployment Target set to 2.2.1. This works fine on my test iPhone device, which is running OS 3.0. The problem is that I don't have a device to test on 2.2.1, so I use the Simulator, and certain UI elements don't show up (mainly images) with my current build. The weird part is that when I test out the old version of my app that's already on the App Store with the current version of XCode on the Simulator, I get the same disappearing UI problem. How can the same build have different results? Did something change in XCode? What's going on here?

Thanks!

2
I'm starting to think this may be some sort of bug on Apple's side. When I take the code that was used to create the build that I submitted to Apple (that was built on 2.2.1) and run on it my 3.0 device, it doesn't work (I get the UI errors). But that same build that I downloaded from the App Store works fine. Something's not right here... - mathew

2 Answers

3
votes

2.2.1 app not working on iPhone Simulator: Check the hardware version of the Simulator from the 'Hardware' > 'Version' menu when the app is running. Though not exactly that same issue, there are problems reported about automatic selection of the right Simulator version. See question#388298 and a related article (see Open Questions). If it's not set to 2.2.1, the only option may be to manually set it and launch the app without debugger.

Supporting backward compatibility in general: Here is a nice write up on doing that. You should check for versions at runtime, not at compile time because the latter will leave out the backward compatible code from the binary. Also, don't forget to weak link any 3.0 only frameworks such as MapKit and GameKit. The article above shows how to do it.

Note: you can check for deprecated property with respondsToSelector:. It's a bit cumbersome but getting and setting a property is just a syntax sugar, so:

cell.image;
cell.image = anImage;
// corresponds to
if ([cell respondsToSelector:@selector(image)]) {
    [cell image];
    [cell setImage:anImage];
}

Also, it might be helpful to keep different targets for each different versions so that you can easily switch between them.

2
votes

Certain methods were deprecated in the 2.2.1->3.0 change, including several UI methods (UITableViewCell's initWithStyle: comes to mind rather readily). I would check to make sure that all your calls to/on UI objects are 3.0-compatible, especially in the areas that construct or display your disappearing objects.