Вот код, если кто-то сталкивается с тем же.
Рабочий процесс iOS 13
Код, полученный из этой статьи: https://medium.com/@ZkHaider/apples-new-uiscene-api-a-programmatic-approach-52d05e382cf2
В вашем файле SceneDelegate:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let windowScene = (scene as? UIWindowScene) else { return }
self.window = UIWindow(frame: windowScene.coordinateSpace.bounds)
self.window?.windowScene = windowScene
let controller = UIViewController()
let navigationController = UINavigationController(rootViewController: controller)
self.window?.rootViewController = navigationController
self.window?.makeKeyAndVisible()
}
iOS 12 и ниже
В вашем файле AppDelegate:
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
let controller = UIViewController()
let navigationController = UINavigationController(rootViewController: controller)
self.window?.rootViewController = navigationController
self.window?.makeKeyAndVisible()
return true
}
Важно, чтобы переменная UIWindow
содержалась в переменной, чтобы она появилась.