How do I run a universal app on the iPhone 3.1.3 simulator?

I'm working on a new app that I want to be universal for the iPhone and iPad. I started out with the "Create a Window-based app" wizard, and it created separate app delegates in "iPhone" and "iPad" groups. Since I already was quite familiar with iPhone dev, I did that part of my project, and now I'm ready to do some iPad stuff.

So... I started out by adding a UISplitViewController to my iPad delegate, switch the Active SDK to 3.2, and it works! But when I switch back to 3.1.3, and try to run it in the simulator, Build and Go fails. For starters, I see:

...path.../iPad/AppDelegate_Pad.h:13: error: expected specifier-qualifier-list before 'UISplitViewController'

I've got my Base SDK set to 3.2 and my Deployment Target set to 3.1.3. I thought that was enough. But I also have found in the documentation this method to conditionally compile:

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200 MyIPadViewController* vc; // Create the iPad view controller #else MyIPhoneViewController* vc; // Create the iPhone view controller #endif

So do I need to do this everywhere? It seems like an awful lot of code to add (that I'll be getting rid of in a short time for 4.0 anyway) so I feel like I must be doing something wrong. And, I don't even have any idea how this works for things like @property or @synthesize declarations.

tl;dr version of the question - did I miss a setting somewhere?

-------------Problems Reply------------

Quite the opposite. A universal app runs the same binary on iPhone and iPad so you cannot use conditional compilation to differentiate between the two version. But you need to use the macro Apple cites in the documentation:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// iPad-specific code
} else {
// iPhone-specific code

I use this C function to help keep the code concise:

BOOL isPad() {
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);

Another thing I do, when I have different xib files for iPhone vs iPad. I have a stripPadSuffixOnPhone() function that helps keep the code simpler:

// Load/create the Delete table cell with delete button
self.deleteCell = [Utilities loadNib:stripPadSuffixOnPhone(@"DeleteCell~ipad")

Things like that can make coding more straightforward and a lot less conditionals. Still have to test everything twice though.

Here's what works for me:

  1. Build your app using SDK 3.2.
  2. Switch the active SDK to iPhone Simulator 3.1.3 (or whatever).
  3. From the Run menu select Debug (not Build and Debug).

The binary built under 3.2 will be installed in the 3.x simulator without rebuilding. When you are finished don't forget to set your active SDK back to 3.2.

Category:iphone Views:0 Time:2010-05-03

Related post

  • iOS Development: How can I prevent an iPad from running a universal app in iPad mode? 2011-02-07

    I'm diving into iOS development and I created a universal app that turned into an iPhone-only app. When it runs on the iPad, it just loads a white screen since there's no iPad code written yet. What I'd like is for it to run in "iPhone" mode on the i

  • iOS: Universal App - Release as iPhone only 2011-05-03

    A customer is interested in releasing a universal app. However, the first release will contain only the iPhone version, the second release will contain both versions. I found a few links where ppl figured out how to make this work in the simulation e

  • Run a universal app as a 'legacy' iPhone app on an iPad 2010-06-05

    I do most development testing on my iPad. When I test an iPhone app, it runs in 'compatibility' mode where the little iPhone app runs in a small window or x2 magnification. Now that I've created a universal app it runs as a native iPad app. For testi

  • How to call [[UIScreen mainScreen] scale] in a universal app for the iphone and ipad 2010-06-28

    I'm making a universal app that will run on both the ipad and the iphone. So far so good, but I have just updated my SDK to ios4 and am wanting to call [[UIScreen mainScreen] scale] (scale is not in the 3.2 sdk and the ipad doesn't have ios4 yet). I

  • Universal Apps concept for iPhone and iPad 2011-05-21

    am a noob at universal apps so please help me out and let me know if this can be done, I am creating a universal app and for doing this i have written the code and made the settings in each of my view controllers present in the iPhone and iPad group

  • iPad app converted as Universal app appears in iPhone new apps? 2012-11-07

    I have an iPad app in the App Store and I'm currently converting it to iPhone as an Universal app. I'm wondering if this app will appear in the App Store as a new app for iPhone? --------------Solutions------------- No, there will be one app. Wich wi

  • universal app target for iphone & ipad - 2 app error 2011-02-08

    Really would appreciate it if you can help me with something. I have searched every websites and apple documentation but cannot find an answer for the following issue I have: I have upgraded an iphone app with the intention of having 1 universal 'tar

  • How to make a universal app (iPad and iphone 4.1) runs on iPod 3.1.3 2010-10-08

    I am building a universal for iphone/ipad and I already set the deployment target to 3.0. It can run well on iPad 3.2 and iphone 4.1. However, when I build and run it on my iPod 3.1.3, the runtime automatically picks the iPad code path and tell me th

  • How to test-run my own app on my iPhone 2012-01-05

    This is not an app that is ready to go out nor is it something that is even in a beta. As you guys know, there are some things that the simulator cannot ..well.. simulate . The accelerometer for example has to be on iPhone. Is there a way for me to j

  • UIView in .XIB on Universal App always reports iPhone UI size 2011-11-13

    I am trying to port an iPhone app to iPad with as little work as possible and I am stuck on one last point. I have a custom UI element that sits along the bottom of the screen. The UI element is simply a subclass of UIView with some delegate methods

  • Instruments always launches iPad Simulator for Universal Apps with Automation, how can I force it to use the iPhone Simulator? 2010-12-03

    I've created a universal binary using iOS 4.2 and Xcode 3.2.5. I'm trying to do some automation testing on the application and since the interfaces are slightly different between the iPad and iPhone versions, I have separate UIAutomation scripts. Unf

  • Could not locate an NSManagedObjectModel for entity name - Universal App 2011-06-15

    I have a strange error in my app, which says: * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Book' I know, there are hundrets of "Coul

  • Convert from Universal App to iPhone? 2011-12-15

    I have a MonoTouch project from a year ago which was created as a universal app (but only programmed like a iPhone app. Just in case...) When I uploaded it on an iPad it was shown in this iPhone simulator. I changed the Target from Universal to iPhon

  • iPhone & iPad: Is an OpenGL ES Universal App a pain to write for multiple devices? 2010-11-12

    I've had experience writing a cocoa touch app as a universal app (for ipad, iphone) and it wasn't too hard. I only needed to use different .xib for each device but atleast it was the same binary. Is it possible to have a universal opengl es app as we

  • Building a universal app for iOS 3.1, iOS 3.2 using iOS SDK 4.2 2011-02-01

    I have a universal app which was originally built for iOS4.2. Since this project does not use many 4.0+ specific APIs, I would like to build this app with deployment target set to 3.1. It gets built with no problems. But when I install and start the

  • AppStore Submission: Query about Universal App 2011-06-07

    I have recently created a Universal App in Xcode 4 to build my new app. I have completed the iPad component only and intend to submit it to the app store. My question is, do I need to create a new iPad specific app for the submission or can I submit

  • Combining iPhone/iPad apps into one universal app 2010-04-24

    I have two apps (one for the iPhone, the other for the iPad) that I'd like to combine into one universal app. For my first attempt, I tried creating a new universal app project and added the libraries for the iPhone and iPad versions. The iPad versio

  • iPhone universal app. MoviePlayer.framwork problem 2010-05-25

    I have application based on 3.0 iPhone OS SDK One of tasks is playing video (I use MPMoviePlayerController for this task) Now I try to make universal app working on both 3.0 and 3.2 OS I did all steps described in apple documentation: Upgrade Current

  • distribute iphone universal app 2010-06-15

    When you distribute an iphone/ipad universal app do you compile it against the 3.1.3 SDK or 3.2? When are some of the settings? --------------Solutions------------- I just built an app with 3.1.2 that was just accepted into the app store. Building wi

Copyright (C), All Rights Reserved.

processed in 0.074 (s). 11 q(s)