iOS

Create an app on iOS 13 or later without using SceneDelegate

ios13-sccenedelegate-en

Create an app on iOS 13 or later without using SceneDelegate

Scene Delegate is standard equipment from iOS 13!

SceneDelegate is a mechanism used when launching the same application multiple times. Most Apple apps are supported.

However, for technical reasons, if you want to prevent multiple launches, or if you do not need to launch multiple, you may want to develop with AppDelegate alone, without using SceneDelegate as in iOS 12 or earlier.
(We have to manage both AppDelegate and SceneDelegate …).

I have investigated what to do in such a case, so I will post it as a memorandum.

Verification environment

  • Xcode11.3
  • iOS13.3

    There are 3 steps required to de-Scene Delegate!

    1. Delete the following method written in AppDelegate.swift.

        // MARK: UISceneSession Lifecycle
    
        func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
            // Called when a new scene session is being created.
            // Use this method to select a configuration to create the new scene with.
            return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
        }
    
        func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
            // Called when the user discards a scene session.
            // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
            // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
        }

    2. Info.plistのUIApplicationSceneManifestのkeyを削除

    Delete all the keys of UIApplicationSceneManifest in info.plist for each item. This item describes the settings related to the operation of the Scene of the app. If you don’t use SceneDelegate, you don’t need it.

    3. Added window to AppDelegate.swift

    Add var window: UIWindow? To AppDelegate.swift. Now all you have to do is delete the SceneDelegate.swift file!

    Please point out any corrections!

    0

    COMMENT

    Your email address will not be published. Required fields are marked *

    CAPTCHA