Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to : Debug UIWindows were created prior to initial application activation

My console posted this error today, [ApplicationLifecycle] UIWindows were created prior to initial application activation. This may result in incorrect visual appearance.

This has caused Application UI to not behave properly. I have never seen this before and need some insight on where to start debugging.

macOS: Catalina 10.15
XCode version: Version 11.1 
like image 631
Joshua Avatar asked Nov 08 '19 19:11

Joshua


1 Answers

I think that apps main UIWindow should be lazily initiated. Try with this:

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    lazy var window: UIWindow? = UIWindow(frame: UIScreen.main.bounds)

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        window?.rootViewController = RootViewController() // root view controller
        window?.makeKeyAndVisible()

        return true
    }
}

like image 152
Aron Balog Avatar answered Nov 13 '22 13:11

Aron Balog