func didPickDocument(document: Document?) {
if let pickedDoc = document {
let fileURL = pickedDoc.fileURL
let data = try Data(contentsOf: fileURL)
class ViewController: UIViewController, DocumentDelegate {
override func viewDidLoad() {
super.viewDidLoad()
@IBAction func actionButtonTapped(_ sender: Any) {
let documentPicker = DocumentPicker(presentationController: self, delegate: self)
documentPicker.displayPicker()
/// callback from the document picker
func didPickDocument(document: Document?) {
if let pickedDoc = document {
let fileURL = pickedDoc.fileURL
/// do what you want with the file URL
print(fileURL)
let data = try Data(contentsOf: fileURL)