UIDocumentPickerViewController unusable - The requested app extension could not be found

249 Views Asked by At

I am seeing the following error while trying to use UIDocumentPickerViewController in the simulator:

Error: the requested app extension could not be found

This in a production app that used to work fine. It reproduces in a minimal xcode project with one button that launches UIDocumentPickerViewController. I've tried following every tutorial I can find and downloading sample projects, and each one of them results in the same error. I'm using Xcode 12.3 and targeting iOS 14.

Is UIDocumentPickerViewController somehow completely broken and on one noticed, or (more likely) is there a step I'm missing?

Here are the steps I've taken to reproduce this

  1. Create a project in xcode 12.3 that uses Storyboards, UIKit Delegate app lifecycle and swift
  2. under Signing and Capabilities, add iCloud and Keychain Sharing (e.g. as described here)
  3. Added a button and the following implementation for ViewController.swift:
import UIKit
import MobileCoreServices
import UniformTypeIdentifiers

class ViewController: UIViewController, UIDocumentPickerDelegate, UINavigationControllerDelegate  {

    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
        print("import result : \(urls)")
    }

    func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
       dismiss(animated: true, completion: nil)
    }

    @IBAction func browse(_ sender: Any) {
        let supportedTypes: [UTType] = [UTType.image]
        let importMenu = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes, asCopy: true)
        importMenu.delegate = self
        importMenu.modalPresentationStyle = .formSheet
        self.present(importMenu, animated: true, completion: nil)
    }

}

Run the app and click the button. The above error is displayed.

The only reference I've found to this error is here: iOS 13: MPMediaPickerController - Internal Error / The requested app extension could not be found

Does the UIDocumentPickerViewController require permissions? I haven't found any indication online.

I've tried variously setting the deployment target to iOS 12 and 13, with no luck. I've also tried initializing the document picker using the deprecated init(documentTypes:..) and the non-deprecated init(forOpeningContentTypes:...), as well as setting containers in the icloud/keychain settings.

I would greatly appreciate any help on this problem.

Thank you!

0

There are 0 best solutions below