How to remove Scene Delegate from iOS Application?
It is a complete solution for empty project generated with Xcode (with storyboard)
- Remove
SceneDelegate.swift
file - Remove
Application Scene Manifest
fromInfo.plist
file - Paste this code to your
AppDelegate.swift
file
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window:UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
window?.makeKeyAndVisible()
return true
}
}
To add to accepted answer: you also need to write this in your AppDelegate:
self.window = UIWindow(frame: UIScreen.main.bounds)
let controller = MyRootViewController()
window?.rootViewController = controller
window?.makeKeyAndVisible()
You need to do the following steps:
- Remove Scene delegate methods from App Delegate and delete the Scene delegate file.
- You need to remove UIApplicationSceneManifest from Info.plist.
You also need to add var window:UIWindow?
if it is not present in AppDelegate
- Remove
SceneDelegate.swift
file - Remove
Application Scene Manifest
fromInfo.plist
file - Add
var window: UIWindow?
to AppDelegate.swift - Replace
@main
with@UIApplicationMain
- Remove
UISceneSession Lifecycle
( functions ) inAppDelegate