In SwiftUI we have been given the onOpenURL(perform:) 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:
@main
struct testURLMacApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL { url in
print("RECEIVED \(url)")
}
}
}
}
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.
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?
EDIT: This is actually for making an existing iOS app work on Apple Sillicon Macs. So AppKit is not available.
