Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anyone has a tutorial on how to create Universal app with XCode 4.2?

It looks like things changed with XCode 4.2 and I did not see any guide/tutorial on how to create a Universal app with XCode 4.2. Anyone knows one or wrote one?

Note: I'm not talking about how to select your project to be Universal, I'm talking about a Hello World tutorial.

Thanks,

like image 924
Van Du Tran Avatar asked Nov 22 '11 19:11

Van Du Tran


2 Answers

In case you actually wanted a plain source, compilable as a universal app that writes Hello World into the console, depending on the device in use, here comes a tiny snippet for you.

main.m

#import <UIKit/UIKit.h>

int main(int argc, char *argv[])
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        printf("hello world, from my iPad");
    }
    else 
    {
        printf("hello world, from my iPhone or iPod");
    }
    return 0;
}

Within the build settings of your app, you will have to select:

TARGETED_DEVICE_FAMILY = 1,2

Like this: enter image description here

like image 158
Till Avatar answered Oct 17 '22 13:10

Till


  • File / new / new project / ios / application / single view application
  • Next
  • fill fields and choose "Universal" in Device Family
  • Next

Xcode will create a project with 2 initial XIBs with same names and different suffix _iPhone and _iPad.

Enjoy!

Good luck!

like image 24
Roberson Balbino Avatar answered Oct 17 '22 13:10

Roberson Balbino