Every now and then, my app launches with a black screen, and the following warning:
Application windows are expected to have a root view controller at the end of application launch
I use storyboards. This tends to happen randomly from time to time when I compile the app, and the error tend only to disappear if I do changes to the code and/or storyboard and then recompile. A bad compilation will continue to launch the app in a bad state even if you restart it.
The only thing unusual (to me) about the app itself is that it's initial view contains a map view, with multiple container views (hidden at launch) on top of it.
I have tried using Spark Inspector to debug the view hierarchy when this happens, and it shows that the only element is the UIWindow, no UIViews are loaded at all.
This is my didFinishLaunchingWithOptions
(which is the only method in the app delegate that has code in it), like Matt requested:
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[DDLog addLogger:[DDASLLogger sharedInstance]];
[DDLog addLogger:[DDTTYLogger sharedInstance]];
[[DDTTYLogger sharedInstance] setColorsEnabled:YES];
UIColor *pink = [UIColor colorWithRed:(118 / 255.0)
green:(214 / 255.0)
blue:(84 / 255.0)
alpha:1.0];
[[DDTTYLogger sharedInstance] setForegroundColor:pink
backgroundColor:nil
forFlag:LOG_FLAG_INFO];
#ifdef DEBUG
DDLogInfo(@"Launching in debug mode");
#else
DDLogWarn(@"Launching in release mode");
#endif
[AFNetworkActivityIndicatorManager sharedManager].enabled = YES;
[[AFNetworkActivityLogger sharedLogger] startLogging];
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil]
setFont:[UIFont fontWithName:@"OpenSans" size:14]];
NSMutableDictionary *titleBarAttributes = [NSMutableDictionary
dictionaryWithDictionary:
[[UINavigationBar appearance] titleTextAttributes]];
[titleBarAttributes setValue:[UIFont fontWithName:@"OpenSans" size:18]
forKey:NSFontAttributeName];
[[UINavigationBar appearance] setTitleTextAttributes:titleBarAttributes];
return YES;
}