I am using xcode 8.3.2 and swift 3.0 ... Here is my code ... it works well ... just call openDocumentPicker (), hope this helps you
extension AddCaseStep3ViewController : UIDocumentMenuDelegate,UIDocumentPickerDelegate{ public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) { let url = url as URL //this is the url of your doc you can send enjoy!! } @available(iOS 8.0, *) public func documentMenu(_ documentMenu: UIDocumentMenuViewController, didPickDocumentPicker documentPicker: UIDocumentPickerViewController) { documentPicker.delegate = self present(documentPicker, animated: true, completion: nil) } func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) { //dismiss(animated: true, completion: nil) } func openDocumentPicker(){ // let documentPicker = UIDocumentPickerViewController(documentTypes: ["public.content","public.data","kUTTypePDF"], in: .import) documentPicker.delegate = self documentPicker.modalPresentationStyle = .formSheet self.present(documentPicker, animated: true, completion: nil) }}
source share