Search code examples
iphonexcodeipadupgradeios-universal-app

Upgrade iPhone-Only app to Universal doesn't create -ipad classes


I'd like to upgrade my iPhone-only app to Universal. So, from the targets' general window I switch from iPhone to Universal and select "copy" for generate iPad Storyboard based on the iphone one. Now a new folder named iPad is created but is empty and I can't find all of the -ipad classes. What I want is to have all of the original (iPhone) classes duplicated with the -ipad suffix and a iPad dedicated Storyboad. Starting from these classes, and from the iPhone logic I want create step by step a new ipad version. In the targets' general windows ipad main interface is main_iphone-ipad but in the project doesn't exist, in the folder neither.


Solution

  • This isn't an issue with Xcode, thats what its supposed to do.

    You can certainly duplicate your entire project for the iPad version manually if you'd like, but I can't think of a case where you'd actually want to do this.

    Most of the time you just want to change the View layer between the iPad and iPhone version. You can load a different Nib based on the device you'd like or even load completely different view controllers doing simple logic like

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
         viewController = [[MyViewController alloc] initWithNibName:@"ipadNIB" bundle:nil];
    } else {
        viewController = [[MyViewController alloc] initWithNibName:@"iphoneNIB" bundle:nil];
    }
    

    ** BEGIN EDIT **

    To setup a different storyboard for iPhone/iPad all you need to do is create another storyboard and name it "myprojectname_ipad.storyboard" then in the Info.plist for your project add a key called "Main storyboard file base name (iPad)" with a value "myprojectname_ipad"

    ** END EDIT **