How to : Debug UIWindows were created prior to initial application activation
Asked Answered
T

1

12

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 
Tressietressure answered 8/11, 2019 at 19:12 Comment(0)
R
22

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
    }
}

Rossie answered 23/12, 2019 at 9:6 Comment(2)
Any source for this?Shalna
Got rid of the warning!! Thank youZischke

© 2022 - 2024 — McMap. All rights reserved.