views:

392

answers:

1

I would like to make a universal build that will run on the iPad and iPhone4. Basically this is the 'HD' build of a game which will run on the higher resolution display devices.

As far as I know, the iPad and iPhone4 both run armv7, so choosing armv6 and armv7 doesn't seem to make sense. Although, this is what Apple tells you to do. I am aware that these instructions were made at the time before the iPhone4 was even out, so I'm curious to know if anyone knows the procedure to build for iPad 3.2 and iPhone 4.0.

If this is covered by the SDK documentation, I'm sorry but I just cannot find it!

As a bonus, I would sort of like to know the definitions for the specific SDK being built so that I can do a compile-time check so that it won't error when running through the 3.2 compile. There's a specific member in the layer class called contentsScale which is now present in 4.0. I just need to know the name of the definition for one or both of those. (3.2 and 4.0)

Thanks a bunch!

Kyle

+2  A: 

If the only devices you wish to support are the iPhone 4 and iPad in your application, you could build only against armv7, which would slightly reduce the size of your executable. However, you will need to add armv7 to the list under the UIRequiredDeviceCapabilities key in your Info.plist to make sure that the App Store listing does not let you install this on an armv6 device. Preventing it from being purchased and run on the armv7 iPhone 3G S and third-generation iPod touch while allowing the iPhone 4 and iPad will be trickier, though.

Otherwise, you would build this application like any other universal application. I recommend either starting from an iPhone project and converting it to a universal application, or starting with a universal application template.

Detecting whether or not a particular method is implemented at runtime can be done using the -respondsToSelector: method. For example, the following code checks for the availability of -contentsScale on a CALayer and adjusts the layer's scale to match that of the display:

if ([self respondsToSelector:@selector(setContentsScale:)])
{
    Class screenClass = NSClassFromString(@"UIScreen");
    if ( screenClass != Nil)
    {
        id scale = [[screenClass mainScreen] valueForKey:@"scale"]; 
        [(id)self setValue:scale forKey:@"contentsScale"]; 
    }
}
Brad Larson
Thanks. With self being the instance of the CAEAGLLayer class, this solution works brilliantly. Thank you!
Kyle