How to open file dialog with SwiftUI on platform “UIKit for Mac”?
问题 NSOpenPanel is not available on platform "UIKit for Mac": https://developer.apple.com/documentation/appkit/nsopenpanel If Apple doesn't provide a built-in way, I guess someone will create a library based on SwiftUI and FileManager that shows the dialog to select files. 回答1: Here's a solution to select a file for macOS with Catalyst & UIKit In your swiftUI view : Button("Choose file") { let picker = DocumentPickerViewController( supportedTypes: ["log"], onPick: { url in print("url : \(url)") }