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

升级Xcode 7+ 之后 ios 9 模拟器 打开第版本的项目 一启动程序 就直接报错
报错如下
Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UIApplication.m:3294**

原因:

新的SDK不允许在设置rootViewController之前做过于复杂的操作,导致在didFinishLaunchingWithOptions 结束后还没有设置rootViewController
Xcode7 需要所有UIWindow必须立即先设置一个rootViewController

解决办法:
先设置个rootVIewController 之后重新赋值

...
self.window.rootViewController = [[UIViewController alloc]init];
...

你可能感兴趣的:(Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UIApplication.m:3294)