iOS App is creating two UIWindow

498 Views Asked by At

I was refactoring an existing project to move away from using .storyboards and removed the initial main interface in .plist, but for some reason the app is creating two instances of UIWindow.

UIWindows

I have no idea on why this is happening, and the result of this is when I do create my actual UIWindow and use makeKeyAndVisible() for a second I get a black screen until the actual rootViewController becomes visible, this happens because in that split of a seconds it shows the first UIWindow which color is nil. If someone has any idea on why this is happening I would appreciate a bunch ;)

EDIT 1:

AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    window = UIWindow(frame: UIScreen.main.bounds)
    appCoordinator.start()

    return true
}

AppCoordinator.swift

func start() {
        let mainVC = UIStoryboard(storyboard: .main).instantiateInitialViewController()
    window.backgroundColor = .white
    window.rootViewController = mainVC
    window.makeKeyAndVisible()
}
1

There are 1 best solutions below

1
On

Check that "Main Interface" is empty:

enter image description here