事象
デバッグビルドをすると下記のエラーを出力してアプリがクラッシュする。
出力されるエラー
*** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.16.3/UIApplication.m:3294
原因
UIApplication.h
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
上記メソッド内で keyWindow に rootViewController が設定されていない。
対策
原因の通り、本事象の発生したアプリでは -application:didFinishLaunchingWithOptions: 内では keyWindow の生成を行いつつも rootViewController の設定をせず、別の場所での処理の後に rootViewController を設定していた。
ここに仮の rootViewController を設定することで解決となった。