When you close your application, your app can still receive silentNotifications or download data in the background, track your location, play music, etc.
In the images below, the encircled red
are for when your app is still doing something, however it is no longer on the screen. It's in the background, so AppDelegate
doesn't need a window
anymore. As a result it will be set to nil
Simple overview

Detail overview

FWIW, the code below won't make the app launch with vc
.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let vc = ViewController()
window?.rootViewController = vc
window?.makeKeyAndVisible()
return true
}
Why it doesn't work? Because the window
property is an optional—initially set to nil.It needs to be instantiated
The code below will work
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let vc = ViewController()
window = UIWindow(frame: UIScreen.main.bounds) // Now it is instantiated!!
window?.rootViewController = vc
window?.makeKeyAndVisible()
return true
}