title: SwiftUI Lifecycle on macOS: present new scene with its own viewmodel
body: <p>I have a macOS app which I'd like to open several instances of in separate windows. For demonstration purposes, I have this tiny example project here:</p>
  <pre class="lang-swift prettyprint-override"><code>import SwiftUI
  
  @main
  struct MultipleWindowsApp: App {
      var body: some Scene {
          WindowGroup {
              MyView()
                  .environmentObject(ViewModel())
                  .frame(minWidth: 200, minHeight: 200)
          }
      }
  }
  
  struct MyView: View {
      @EnvironmentObject var vm: ViewModel
      
      var body: some View {
          Toggle(isOn: $vm.toggleState, label: {
              Text(&quot;Some Toggle&quot;)
          })
      }
  }
  
  class ViewModel: ObservableObject {
      @Published var toggleState = false
  }
  </code></pre>
  <p>As it is, a new window created from the menu bar will have a reference to the same ViewModel instance (toggling in one window toggles the other and vice versa).
  I failed to find a simple answer on how I can have different windows with their own respective viewmodels (please note: I am not handling documents here that need to get saved etc., I am just consuming and visualising an api in my app).</p>