LoginSignup
6
2

XCode15系にアプデしたらアプリがLaunchScreenから先に進まなくなった

Last updated at Posted at 2023-12-18

はじめに

この記事はand factory.inc Advent Calendar 2023 19日目の記事です。
昨日は @ichikawa7ss さんの「なんのためにあるの?逆引きスクラムプラクティス」でした。

起こったこと

  • XCode14.2で開発を進めていたアプリをXCode15で起動したところ、LaunchScreenを表示した後に真っ暗な画面(black screen)から先に進まなくなった

解消方法

  • UISceneConfiguration.delegateClass を指定したら解消

修正前

    /// this shows black screen with XCode 15.0~. (worked when XCode 14.2)
    func application(
        _ application: UIApplication,
        configurationForConnecting connectingSceneSession: UISceneSession,
        options: UIScene.ConnectionOptions
    ) -> UISceneConfiguration {
        return UISceneConfiguration(
            name: "Default Configuration",
            sessionRole: connectingSceneSession.role
        )
    }

修正後

	/// this works with XCode 15.0~
	func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        let sceneConfig = UISceneConfiguration(
            name: "Default Configuration",
            sessionRole: connectingSceneSession.role
        )
        sceneConfig.delegateClass = SceneDelegate.self
        return sceneConfig
    }

学び

  • delegateClassを設定しましょう
  • 公式ドキュメントに記載されている通り、Info.plistのDelegate Class Nameを指定しているので本来修正前のコードで動くはずなのではと思うのですが…(実際XCode14.2では問題なく動作している)

    UIKit sets this property’s initial value using the [UISceneDelegateClassName](https://developer.apple.com/documentation/bundleresources/information_property_list/uiapplicationscenemanifest/uisceneconfigurations/uiwindowscenesessionroleapplication/uiscenedelegateclassname) key from the appropriate scene in your app’s Info.plist file.

補足

  • 今回の事象ですが、XCode14.2環境で自分が開発を進めていた全てのアプリで起こっているわけではありません
  • 発生条件が特定できていないものの、事象の解消はできたので一助になればと思い記事化しています

参照

  • 今回の検証に用いた検証用アプリのレポジトリはこちらです
6
2
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
6
2