I am reading Programming iOS4 by O’Rielly and I am using a slightly newer version of XCode than the one that the book is using. However, this slight change has led to a little bit of confusion because I cannot create window-based app using the XCode 4.2.
Anyhow, I started an empty project which gave me the barebone structure for an iPhone app without the MainWindow.xib. I was already given the project’s delegate .h and .m. I proceeded to create my own MainWindow.xib. I figured out that I had to set ‘Main nib file base name’ to ‘MainWindow’ for my nib to show up at all and so I did that.
Inside my MainWindow.xib, I added a button under the window object just to make sure that I have what I want when I run the project. This is the state of my nib right now

Without making any changes to the AppDelegate.h and AppDelegate.m, I built and ran my project. I was able to see the button! HOWEVER, I could not click on the button and when I pressed the home button and resumed my empty app, I could not see the button anymore! Here are some files that I did not make any changes to:
main.m
#import <UIKit/UIKit.h>
#import "EmptyWindowAppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([EmptyWindowAppDelegate class]));
}
}
EmptyWindowAppDelegate.m
#import "EmptyWindowAppDelegate.h"
@implementation EmptyWindowAppDelegate
@synthesize window = _window;
@synthesize managedObjectContext = __managedObjectContext;
@synthesize managedObjectModel = __managedObjectModel;
@synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
//...Omitted
You can specify the name of the main nib file in your application plist (by default it is MainWindow.xib).
To investigate your problem further you could just create a default view based app and see what the differences are. It seems to me that you have made no connection in interface builder between your App Delegate’s window property and your IB window object. Which means that window, in didFinishLaunchingWithOptions would probably be nil and that the messages you send it will therefore have no effect.