How can I support macOS 10.15 while using SwiftUI's new App type

I'm in the process of adopting some of the new SwiftUI features released in macOS 11, namely using the App type. The result of this is that I need to switch between the new type that's conforming to App and the older AppDelegate in my code based off of the os version running.

To do this, I need to introduce a new main function but am unsure of the syntax required. Does anyone have some pointers as to how I could do such an implementation?

Much thanks.
Answered by mattdelves in 615169022
Sorry, my question may not have been entirely clear. I've got an @availability check around the new stuff. What I needed to do was create a main.swift file that does the switching between the new type which conforms to App and the older AppDelegate implementation. This ended up looking like the following.

Code Block
if #available(macOS 10.16, *) {
  MyAwesomeNewImplementaitonOfApp.main()
} else {
  let app = NSApplication.shared
  let delegate = AppDelegate()
  app.delegate = delegate
  app.run()
}

The new functionality in SwiftUI is part of the SwiftUI framework that’s delivered with macOS 11, thus it’s not something you can back-deploy to an earlier macOS.
Accepted Answer
Sorry, my question may not have been entirely clear. I've got an @availability check around the new stuff. What I needed to do was create a main.swift file that does the switching between the new type which conforms to App and the older AppDelegate implementation. This ended up looking like the following.

Code Block
if #available(macOS 10.16, *) {
  MyAwesomeNewImplementaitonOfApp.main()
} else {
  let app = NSApplication.shared
  let delegate = AppDelegate()
  app.delegate = delegate
  app.run()
}

How can I support macOS 10.15 while using SwiftUI's new App type
 
 
Q