Application windows are expected to have a root view controller at the end of application launch

Frustrated with the error “Application windows are expected to have a root view controller at the end of application launch”?

Here comes the solution.

I faced the error: “Application windows are expected to have a root view controller at the end of application launch” in the following developing environment

OS : Mac OS 10.7.5

IDE : xcode 4.6

iPhone Simulator : 6.1

I’ve created my first “Hello World” project in Mac OS X using XCode developer tool. My application built successfully without throwing any error or warning. But when I am launching my application in iPhone 6.1 Simulator I’ve ended up with this error “Application windows are expected to have a root view controller at the end of application launch” almost for 4 hours. When I’ve googled it, they’ve asked me to perform several number of work arounds which have not solved my problem. Here I’ll describe my problem and the way to retrieve from it.

Error : Application windows are expected to have a root view controller at the end of application launch

Scenario : This error will be displayed in XCode developer tool when your application launched successfully and when a black screen appears in iPhone Simulator.

Description : When your view controller is not rendered(page displayed in Simulator) even after your application built successfully, it means Simulator has issues with its View Controller / nib file / xib file which is responsible to display your page in Simulator.

Solution : We have several solutions for this single error:

1. Check your <ClassPrefixName>AppDelegate.m file for - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method definition which is responsible to define your view controller. It is responsible to send your view controller name to Simulator.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    self.viewController = [[[HelloWorldViewController alloc] initWithNibName:@"HelloWorldViewController" bundle:nil] autorelease];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

2. Check your “File’s Owner” Connection Inspector. Your view should be mapped with the view controller properly and all your other controls and its corresponding outlets should be connected properly.

For Example,

In my Hello World application, I’ve created an interface IBAction to display my String in a label when the user clicks or taps “Click Here” button.

In “HelloWorldViewController.xib” file, when I click File’s Owner under Placeholders, Connection Inspector should display “Label”, “View” under “Outlets” and  “Button” under “Received Actions”

To display “Hello String..” in my simulator, I need to connect

  • view with my xib file
  • “label”(which is a variable I’ve created in my HelloWorldViewController.m file) with my label control
  • “button”(which is a variable I’ve created in my HelloWorldViewController.m file) with my button control
  • after connecting “button” action with button control, we need to select the action type when it should be triggered. (For example, select “Touch up inside” if the action should trigger when the user taps or double taps or click “Click Here” button)
View Controller Connection Inspector

View Controller Connection Inspector

3. It will take some time to load your changes in Simulator. So, clean and build your project again to render properly

4. Go To Product -> Scheme -> Edit Scheme -> Select Run HelloWorldApp (your app) from left menu and select info tab. Make sure, your app is selected in Executable.

Edit Scheme in XCode Tool

Edit Scheme in XCode Tool

If none of the above works, visit below links:

http://stackoverflow.com/questions/7520971/applications-are-expected-to-have-a-root-view-controller-at-the-end-of-applicati

http://stackoverflow.com/questions/11515818/application-windows-are-expected-to-have-a-root-view-controller-at-the-end-of-ap

 

Share This Post

Related Articles

Leave a Reply

© 2017 Techy Diary. All rights reserved.
Powered by Charvi Groups