Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 891 Bytes

README.md

File metadata and controls

36 lines (25 loc) · 891 Bytes

DocumentPicker is a SwiftUI view modifier to show/hide the system's document picker. Fully compatible with the macOS, iOS, iPadOS and Mac Catalyst platforms.

Demo

Example

struct ContentView: View {

  @State var showDocPicker = false

  var body: some View {
    Button("Show document picker") {
      self.showDocPicker.toggle()
    }
    .documentPicker(
      isPresented: $showDocPicker,
      documentTypes: ["public.folder"],
    ) { urls in
      print("Selected folder: \(urls.first!)")
    }
  }
}

More info in the docs.

Installation via SPM

In XCode add the following URL to your project's Swift Package dependencies:

https://github.com/swiftuilib/document-picker

Development

To modify the package contents while still being able to see SwiftUI Previews use the provided DocumentPickerPreview.xcodeproj.