1

I just tried to run my project with the new XCode7 beta4 but is giving me this exception immediately after running the simulator:

Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:],/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3491.2.5/UIApplication.m:3173 

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'

I read that maybe can be a problem with setting rootViewVontroller of the main window but my code in the AppDelegate.m file is this one:

[self.tabBarController setViewControllers:tabViewControllers];

[self.tabBarController setCustomizableViewControllers:customizableControllers];

[self.window setRootViewController:self.tabBarController];

where the tabBarController class is a custom UITabViewController. I DONT use any .xib file in my project! Anybody have an idea how i can proceed?

Thanks in advance

Denis Bulgarini
  • 143
  • 3
  • 11
  • Did you run the conversion and get rid of all warnings first? It ran fine on Xcode 6.x, right? – rholmes Jul 24 '15 at 14:00
  • What do u mean for "conversion"? I did "Update to raccomended Setting" but i didnt get rid of the warnings.. but are really silly warnings like (- (NSUInteger)supportedInterfaceOrientations to be update to - (UIInterfaceOrientationMask)supportedInterfaceOrientations). Do u have an idea to wat can be @rholmes? – Denis Bulgarini Jul 24 '15 at 14:09
  • 1
    Check the updates to the answer. In particular, did you try (1) targeting previous iOS (8.x) in Xcode 7 (2) using source control diff to see if anything inadvertently changed. – rholmes Jul 29 '15 at 20:48

4 Answers4

1

Had the same issue with nearly everything, sample code form PowerVR, even sample code from Apple sometimes.

I believe this is an iOS 9 issue (it would appear 9 is stringent on this point). For compliance with iOS 9, there must be a call to setRootViewController at some point before application launch as completed.

In order to proceed, especially with older code, I downloaded iOS 8.4 and iOS 8.1 simulators. Targeting them with the exact same code resulted in a functioning project, just as it was with older Xcode builds.

Similar results occur with devices; targeting a device on a pre-iOS 9 OS results in normal operation (though the console does show a complaint regarding the root view controller (says Application Windows are expected to have a root view controller)), the app runs.

It would appear this is some deprecated design requirement - the 'allowance' of running code without a root view controller was, it seems, warned in earlier versions, but as of iOS 9, it seems to be formally required.

Some code has no such provision, so, for example, in the PowerVR example code from SDK 3.5 (fairly recent - highest release as of 9/12/15) one must create a view controller of some kind (their code doesn't appear to have one).

JVene
  • 1,611
  • 10
  • 10
1

Set your self.window.rootRootController after [self.window makeKeyAndVisible] may fix this issue.

This worked for me

Stan
  • 142
  • 4
1

Issue occurred in Xcode 7.0.Solution is Replace this code in your main.m file.

int main(int argc, char * argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}
orkoden
  • 18,946
  • 4
  • 59
  • 50
Hardip Kalola
  • 196
  • 1
  • 4
0

First, try the normal steps to ensure consistency:

  • Clean the project
  • Clear any data from simulators you're using

Next, ask yourself the following questions:

  1. Did it run successfully in the previous version of Xcode?
  2. Did you change anything other than necessary conversions for the new Xcode? (Use version control diff).
  3. Are all warnings addressed (or at least understood)? (I'd make sure that all of them were fixed).
  4. Did your target SDK / device change? (Try it again targeting the previous iOS version and see if that fixes it).

Using the diff feature of your version control system can help with questions 1 and 4. This can help detect inadvertent changes, such as a typo or deletion of an interface builder element.

Warnings are relevant because there may be SDK changes you're not informed about. Ensuring you're still targeting the same SDK can reduce uncertainty in this regard.

Some changes that can cause this type of error are:

Community
  • 1
  • 1
rholmes
  • 4,064
  • 3
  • 25
  • 34
  • I did it, i clean the project, clear data in the simulator, but still give the error. The project is running successfully in the previous version of XCode, i cannot understand what i can do more to find out witch changes i can do to make it runnable again. Please help – Denis Bulgarini Jul 29 '15 at 12:15
  • Do a diff on your story board. Make sure that the root view controller is still set in interface builder. – rholmes Jul 29 '15 at 16:33
  • I don't have xib, storyboard and i never the interface builder. sorry :( i don't really know what can be at this point. – Denis Bulgarini Jul 30 '15 at 15:39
  • Just for clarification- what was the last Xcode / iOS versions you last were successful with? Might narrow do the possibilities... – rholmes Jul 30 '15 at 16:09
  • The lastest XCode i used is 6.4 and the min target is 7.0. It's not a old project but i always refuse to use any interface builder, i write all the code. – Denis Bulgarini Jul 30 '15 at 16:45