Xcode 7.2.1中运行Xcode 5中的Empty工程导致崩溃

时间:2021-12-04 08:54:49

1.现象

2016-05-06 10:46:56.090 Demo[1138:58497] *** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.30.14/UIApplication.m:3315
2016-05-06 10:46:56.097 Demo[1138:58497] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'
*** First throw call stack:
(
0 CoreFoundation 0x0000000105807e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010527edeb objc_exception_throw + 48
2 CoreFoundation 0x0000000105807cca +[NSException raise:format:arguments:] + 106
3 Foundation 0x0000000104eca4de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4 UIKit 0x00000001038e8218 -[UIApplication _runWithMainScene:transitionContext:completion:] + 3122
5 UIKit 0x00000001038e4e7b -[UIApplication workspaceDidEndTransaction:] + 188
6 FrontBoardServices 0x00000001086ea754 -[FBSSerialQueue _performNext] + 192
7 FrontBoardServices 0x00000001086eaac2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
8 CoreFoundation 0x0000000105733a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
9 CoreFoundation 0x000000010572995c __CFRunLoopDoSources0 + 556
10 CoreFoundation 0x0000000105728e13 __CFRunLoopRun + 867
11 CoreFoundation 0x0000000105728828 CFRunLoopRunSpecific + 488
12 UIKit 0x00000001038e47cd -[UIApplication _run] + 402
13 UIKit 0x00000001038e9610 UIApplicationMain + 171
14 Demo 0x00000001035cf9cf main + 111
15 libdyld.dylib 0x00000001066bb92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

 2.原因

  由于没有设置rootViewController。

3.解决方案

  设置rootViewController即可。

4.相关文档

  iOS9新特性 window决定程序的状态栏管理问题(转)