title: Handle multiple URLs from Open With in SwiftUI on Mac
body: <p>In SwiftUI we have been given the <a href="https://developer.apple.com/documentation/SwiftUI/View/onOpenURL(perform:)" rel="nofollow noreferrer">onOpenURL(perform:)</a> function. However, in macOS we can select multiple files in Finder and click on Open With. If I open these files with an app with code such as:</p>
  <pre><code>@main
  struct testURLMacApp: App {
      var body: some Scene {
          WindowGroup {
              ContentView()
                  .onOpenURL { url in
                      print(&quot;RECEIVED \(url)&quot;)
                  }
          }
      }
  }
  </code></pre>
  <p>it appears this function does not work properly for multiple files. It appears to sometimes to call the perform closure once, or sometimes if lucky 2-3 times max in succession. Sometimes it appears to do weird things like open a duplicate app window.</p>
  <p>Has anyone found out a workaround for this, or the proper way of handling opening multiple files in a single window in a SwiftUI app?</p>
  <p>EDIT: This is actually for making an existing iOS app work on Apple Sillicon Macs. So AppKit is not available.</p>