views:

1227

answers:

3

Hi everyone!

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  A: 

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.

Tim
Yes, I am using deprecated methods and properties, like the property 'image' of UITableViewCell, and these are the elements that aren't showing up. But what's the workaround? The new methods and properties are only supported on OS 3.0. Any why would the deprecated methods not work on the older version of the OS and still work on the newer one?
mathew
There are a few things you can try. First, change your Base SDK back to 2.2.1. A deprecated method in 3.0 should still work if the program is being built for the older OS. If that doesn't work, you can start experimenting with `#ifdef` in your source files to run the appropriate code per-OS; the preprocessor symbol `__IPHONE_3_0` is defined on 3.0+ systems, and is not on anything <=2.2.1.
Tim
The Base SDK on the older version was already set to 2.2.1 and that's the version that doesn't work. I double checked that the simulator was running on 2.2.1. The build that I am using is the one that I tagged in Subversion and sent to Apple so there shouldn't be any problems.
mathew
+3  A: 

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.

ento
Thanks for the links, but I still have the same problem. When I ran the old version of the app, I confirmed that the Simulator was running version 2.2.1 and icons are still not showing up. I'm not using any 3.0 libraries either (just Foundation, UIKit, CoreGraphics, and sqlite).I wouldn't be surprised if the 3.0 version wasn't working, but I can't fathom why the same code that's on the App Store suddenly doesn't work any more on 2.2.1.
mathew
A: 

Mathew, did you find an answer to your questions. I am running into the same issues and any experience sharing would be much appreciated!

ilyaeck
i have your answer unknown(google) tell me where you stuck
Rahul Vyas
I actually never really solved this problem. I would love to hear a proper solution.
mathew