0

I have received a project from a client that I need to compile, but when I run it gives error Application windows are expected to have a root view controller at the end of application launch and EXC_BAD_Access (code=2, address=0x0)

as far as I know this is due to application:didFinishLaunchWithOptions: in the AppDelegate, but the problem with my project is that there is no AppDelegate file.

EDIT:

I tried to run the project on Xcode 4.5.1 now it is giving the error address doesn't contain a section that points to a section in a object file.

Ankur Arya
  • 4,693
  • 5
  • 29
  • 50
  • b.t.w., that's "root view controller" line is not a compiler error but a **warning**. The second line ("`EXC_BAD_ACCESS`") is a true crash from somewhere else in your code. – Michael Dautermann Nov 21 '12 at 07:44
  • I presume this error `EXE_BAD_ACCESS` is due to the reason that application didn't find the root view controller. – Ankur Arya Nov 21 '12 at 08:03
  • not necessarily... look at the console log of the `EXC_BAD_ACCESS` crash and it should show a backtrace of where the crash actually happened. – Michael Dautermann Nov 21 '12 at 08:03

2 Answers2

0

The problem is that there is no AppDelegate file. That is usually where the root view controller is set

- (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 = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];

  // set root view controller
  self.window.rootViewController = self.viewController;
  [self.window makeKeyAndVisible];
  return YES;
}
Jesse Black
  • 7,966
  • 3
  • 34
  • 45
0

I also experienced the "Application windows are expected to have a root view controller" error message.

If you are using a storyboard and you have verified:

  1. The app delegate application:didFinishLaunchingWithOptions method is returning TRUE and doing nothing else.
  2. The view controller is set in IB to be the initial view controller.
  3. The storyboard is appropriately set on the TARGETS Summary tab.

Verify that you have not created a "view" UIView @property and @synthezised it in the view controller implementation. I experienced this and through a lengthy process of elimination had my DOH moment when I realized I had created a "view" UIView property named exactly like the one IB had created and linked to the view controller.

Hope this helps.

madZack
  • 21
  • 3