A small Swift UI Package with one View to select a file.
Simple example:
@State private var fileURL: URL?
...
var body: some View {
...
FileSelectorView(allowedFileTypes: ["txt", "md"], url: self.$fileURL)
...
}
With a label in the body:
var body: some View {
...
HStack(alignment: .firstTextBaseline) {
Text("Text file:")
FileSelectorView(allowedFileTypes: ["txt", "md"], url: self.$fileURL)
}
...
}
You can check out the complete documentation here.
The library supports the Swift Package Manger, so simply add it to the Swift Packages tab of your Xcode project.