title: viewWillAppear and later lifecycle events not called when UIViewController is set as root of UIWindow during launch
body: <p>I have the following piece of code in my <code>application(_:didFinishLaunchingWithOptions:)</code> method</p>
  
  <pre><code>self.window = self.window ?? UIWindow()
  self.window?.makeKeyAndVisible()
  let mainViewController = HomeViewController.instantiate() //here I just call the viewController through storyboard, set some properties and return its instance
  window?.rootViewController = mainViewController
  </code></pre>
  
  <p>I checked and the only lifecycle events that are called when the <code>viewController</code> is added to the <code>window</code> are:</p>
  
  <pre><code>viewDidLoad
  viewWillLayoutSubviews
  viewDidLayoutSubviews
  </code></pre>
  
  <p>Anything after that is not called (this happens only when it is initially  added in the <code>window</code>, after that the events are called as they are supposed to). Safe Layout Guide is also not set (and I believe the same goes with other view properties). In order to bypass this issue I do the following:</p>
  
  <pre><code>window?.rootViewController = UIViewController()
  </code></pre>
  
  <p>and then</p>
  
  <pre><code>window?.rootViewController = mainViewController
  </code></pre>
  
  <p>It seems that this somehow forces the window to work correctly the second time it has its root view controller set. </p>
  
  <p>However it seems that either there is something I am missing or there is some kind of lifecycle issue.</p>
  
  <p><em>Has anyone faced the same issue and found the underlying cause?</em> </p>