Running Universal iPad/iPhone Apps in the Simulator
So a couple of days ago I was getting irked by the fact that my Universal app always runs in iPad mode in the Simulator. The application contains code for both the iPad, using all the nice new OS 3.2 APIs, and for the iPhone using 3.0 APIs. However, since it needs to be built against the 3.2 SDK, launching it from Xcode installs it only on the 3.2 Simulator, which only runs in iPad mode.
All in all, very frustrating. Until I figured out the simple way around it earlier today.
It turns out that you don’t have to build your app to have it installed in the simulator, you just have to run it. As a result, you can change your target SDK after building your app, and the newly-built binary will be copied as-is into the appropriate Simulator folder when you run or debug it.
This means that to test your 3.0/3.2 iPhone/iPad app in iPhone mode, with the debugger, you can follow these simple steps:
- Build your application for the Simulator 3.2 SDK. Just build (⌘B) it, not ‘build and run’.
- Change your target SDK to ‘Simulator - 3.0’.
- Run (⌘⌥R) or Debug (⌘⌥Y) your application.
- Watch the Simulator fire up in iPhone mode running OS 3.0, with your application installed and launching.
The only downside to this is that it’s very easy to forget about switching back to the 3.2 SDK when you next need to recompile, especially if you’re in heavy debugging mode. It’s pretty easy to just hit Build again and find yourself looking at a list of hundreds of compile errors from your 3.2-only calls, realizing that you’ve just replaced most of your compiled object files from the 3.2 build. Eep.
Perhaps someone on the Xcode team would add some explicit support for choosing a simulator SDK hardware target independently of changing the build SDK target. That would be great.