Porting iPhone Apps to iPad
I finally started porting my iPhone apps to the iPad. At first I avoided the subject like the plague… mostly because i thought it was going to be a pain in the ass and didn’t think I had the time to do it. But its really simple.
Assumptions:
- You’ve been developing for iPhone and have submitted an app or 2 to the iTunes store.
- You want an app that will work for both iPad and iPhone. Not an separate iPad application with enhanced features.
Step 1: Download and install iPhone 3.2 SDK
You can find it here on Apple’s site. (unless they change the link)
Step 2: Change the SDK and Targets
- Change Base SDK to iPhone OS 3.2
You can find this under Project Properties. - Change Targeted Device Family:
Select the Targets item and click the info button. In the Build tab under the Deployment section, select “iPhone/iPad” for the Targeted Device Family. - Change iPhone OS Deployment Target to iPhone OS 3.2
If you are worried about your iPhone customers that have NOT upgraded to the latest and greatest, select a lower OS Deployment Target. For example: iPhone 3.0
Step 3: Update your views to support iPad
The good news is, iPad uses the exact same code as iPhone. What you will need to do is change your code to support both iPhone (320×480) and iPad (1024×768) resolutions. I’m not going to go into specifics of how to change your view (because each app will differ), but here are some tips on detecting iPad vs iPhone.
Detecting the Device:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// iPad
} else {
// iPhone
}
This is all you need if you only want to target the 3.2 OS. But if you are worried about your iPhone customers that have NOT upgraded to the latest and greatest, this will not work.
When you try to test using a lower iPhone OS Deployment Target (for example iPhone OS 3.0), this will throw an error and not compile because these properties do not exist in older SDKs.
The way I get around this is to define these properties in my Prefix header for all source files (xxx_Prefix.pch):
#ifndef __IPHONE_3_2
typedef enum {
UIUserInterfaceIdiomPhone,
UIUserInterfaceIdiomPad,
} UIUserInterfaceIdiom;
#define UI_USER_INTERFACE_IDIOM() UIUserInterfaceIdiomPhone
#endif
Now you should compile fine with any SDK.
Cocos2D Developers
If you are using a framework such as Cocos2d, you can use the frameworks ability to detect screen resolution instead. For example:
CGSize winsize = [[CCDirector sharedDirector] winSize];
if ((winsize.width == 1024 && winsize.height == 768 ) || (winsize.width == 768 && winsize.height == 1024)) {
// iPad
} else {
// iPhone
}
You will still need to use the UI_USER_INTERFACE_IDIOM technique described above if you are trying to detect the device from your app delegate. For example, setting the screen orientation if you want your app to run in portrait if iPad and in landscape if iPhone. Probably because the view has not been created yet.
Disclaimer & Support
I’m not Yoda when it comes to iPhone development. I just like sharing my thoughts and experiences with other developers. If I’ve made a mistake, email me and ill update the blog if I have time. I disabled comments because of spammers.
If this was helpful, please support my ass by buying one of my 99 cent apps. Search for “Planet Sucko” in the iTunes store.



Step 2: Create the Image to be Masked

Alright, I’ll be honest, you had me at hello… but once I got to know you…