I get the following error in my console:
Applications are expected to have a root view controller at the end of application launch
I got this when starting with the "Empty Application" template and then manually adding a XIB. I solved it by setting the main Nib name as suggested by Sunny. The missing step in this scenario is removing
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
from
application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
As it will overwrite the instance of your window created in the Xib file. This is assuming you have created a ViewController and wired it up with your window and App Delegate in the XIB file as well.
This occurred for me because i inadvertently commented out:
[self.window makeKeyAndVisible];
from
- (BOOL)application:(UIApplication*) didFinishLaunchingWithOptions:(NSDictionary*)
On top of "sho" answer, that is correct (fourth parameter of UIApplicationMain should be the name of the main controller), I add some comments.
I have recently changed the 'model' of an app of mine from using MainWindow.xib to construct a window programatically. The app used an older template that created that MainWindow automatically. Since I wanted to support a different controller view XIB for iPhone 5, it is easier to choose the right XIB programatically when the App Delegate is created. I removed MainWindow.xib from project as well.
Problem was, I forgot to fill the fourth parameter in UIApplication main and I FORGOT TO REMOVE MainWindow from "Main Interface" at Project Summary.
This caused a BIG problem: it rendered the harmless warning "Applications are expected to..." on development devices, but when it went to App Store, it broke on consumer phones, crashing because MainWindow was no longer in the bundle! I had to request an expedited review for the bugfix.
Another sympthom is that sometimes a white block, like a blank UIView, was sometimes appearing when Settings were changed and app was put in foreground. In iPhone 5 it was clear that it was an 320x480 block. Perhaps the missing MainWindow was being created in development mode, using the old size. I had just found this bug when the first reports of the crash reached the inbox.
Installing the app from App Store instead of from XCode showed that the app indeed crashed, and the MainWindow issue revealed itself on log, so I could see that it was not some special combination of devices+IOS versions.
I had this same problem. Check your main.m. The last argument should be set to the name of the class that implements the UIApplicationDelegate protocol.
retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
This error also show up when file's owner of MainWindow.xib is set incorrectly.
File's owner is UIApplication
->inserted object of app delegate class with window outlet connected to window
I had this same error message in the log. I had a UIAlertView pop up in application:didFinishLaunchingWithOptions. I solved it by delaying the call to the alertView to allow time for the root view controller to finishing loading.
In application:didFinishLaunchingWithOptions:
[self performSelector:@selector(callPopUp) withObject:nil afterDelay:1.0];
which calls after 1 second:
- (void)callPopUp
{
// call UIAlertView
}