LoginSignup
11
10

More than 5 years have passed since last update.

Xcode 7 でビルドしたアプリが起動直後に Assertion failure

Last updated at Posted at 2015-09-15

事象

デバッグビルドをすると下記のエラーを出力してアプリがクラッシュする。

出力されるエラー

*** 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 を設定することで解決となった。

11
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
10