Window-based Application template in xCode 4.2

This content has 10 years. Please, read this page keeping its age in your mind.

Many tutorials has been written based on older xCode versions. Before 4.2 there was a convenient “Windows based Application”
containing a MainWindow.xib.

So what if you want to code an older version tutorial having 4.2 xCode?

Follow the steps bellow:

1. Create an “Empty Application” template project (remember to deselect Storyboards and ARC from the available options).
2. Open main.m file, find the function UIApplicationMain(), and make the last argument nil

@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([HelloWorldAppDelegate class]));

@autoreleasepool {
return UIApplicationMain(argc, argv, nil, nil);

3. Open AppDelegate.h and put an IBOutlet in front of the window property.

@property (strong, nonatomic)UIWindow *window;
@property (strong, nonatomic) IBOutlet UIWindow *window;

4. Create a new Window XIB from the templates and name it MainWindow.
5. Make the File’s Owner Identity a UIApplication (by selecting it, opening the utilities area, selecting the Identity inspector, and changing the Custom Class field).
6. Add a NSObject to the XIB Object’s list, change the custom class of this object to AppDelegate (the same way you did for the File’s Owner).
7. Connect the window outlet of the AppDelegate to the Window object.
8. Connect the delegate outlet of the File’s Owner to the AppDelegate.
9. Select the project. Select the target. Enter MainWindow into the Main Interface field.
10. Remove the following lines from AppDelegate.m:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];

[Thanks to Joe Conway from forum and the great book iPhone Programming: The Big Nerd Ranch Guide he has written]