How to run a universal application on a simulator iPhone 3.1.3?

I am working on a new application that I want to be universal for iPhone and iPad. I started with the Create from Window wizard and created separate application delegates in the iPhone and iPad groups. Since I was already familiar with iPhone dev, I did this part of my project, and now I'm ready to do some things for the iPad.

So ... I started by adding the UISplitViewController to my iPad delegate, switched the active SDK to 3.2, and it works! But when I go back to 3.1.3 and try to run it in the simulator, Build and Go will fail. To start, I see:

... path ... / iPad / AppDelegate_Pad.h: 13: error: expected specifier-classifier-list before "UISplitViewController"

I have the base SDK installed at 3.2, and my deployment target level is at 3.1.3. I thought that was enough. But I also 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 what do I need to do this everywhere? There seems to be a lot of code to add (that I will get rid of 4.0 for 4.0 soon), so I feel like I have to do something wrong. And I don’t even know how this works for things like @property or @synthesize.

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

+10
iphone build-process xcode ipad
May 03 '10 at 15:41
source share
3 answers

Quite the contrary. The universal application runs the same binary code on the iPhone and iPad, so you cannot use conditional compilation to distinguish between two versions. But you need to use the Apple macro quoted in the documentation:

 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { // iPad-specific code } else { // iPhone-specific code } 
+23
May 03 '10 at 15:48
source share

I use this C function to keep the code concise:

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

Another thing I do when I have different xib files for iPhone and iPad. I have a stripPadSuffixOnPhone () function that helps simplify the code:

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

Such things can make coding simpler and much less conditional. Nevertheless, you have to check everything twice.

+39
May 03 '10 at 16:04
source share

Here is what works for me:

  • Build the application using the SDK 3.2.
  • Switch the active SDK to iPhone Simulator 3.1.3 (or something else).
  • From the Run menu, select Debug (not Build and Debug).

A binary file built under 3.2 will be installed in the 3.x simulator without rebuilding. When you're done, remember to set the active SDK to 3.2.

0
Jun 06 2018-10-06T0013
source share



All Articles