UIImagePickerController extension discovery failed with error: (null)

Viewed 2004

I'm trying to implement an ImagePicker on my ViewController, but turns out it presents a blank ImagePicker Controller and UIImagePickerController extension discovery failed with error: (null) message on the console.

I have no idea what I'm doing wrong, and I found no information on the matter. One thing I noticed, though, is that the PickerView takes a little bit too long to be presented.

The code related to the ImagePicker is the following:

private let imagePicker = UIImagePickerController()

private func setupImagePicker() {
        imagePicker.sourceType = .photoLibrary
        imagePicker.allowsEditing = false
        imagePicker.delegate = self
        imagePicker.mediaTypes = ["public.image"]
}

    @objc private func launchImagePicker() {

        let photos = PHPhotoLibrary.authorizationStatus()
        if photos == .notDetermined {
            PHPhotoLibrary.requestAuthorization({ [weak self] status in
                DispatchQueue.main.async {
                    if status == .authorized, let picker = self?.imagePicker {
                        self?.present(picker, animated: true, completion: nil)
                    } else {
                        self?.present(URealtorUtils.getAlert(message: "You have to authorize photo library access in order to upload a photo"), animated: true, completion: nil)
                    }
                }
            })
        } else if photos == .authorized {
            present(imagePicker, animated: true, completion: nil)
        }
    }

extension MyController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {

    func imagePickerController(_ picker: UIImagePickerController,
                               didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
        if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
            self.viewModel.setPropertyImage(image)
        }
        dismiss(animated: true, completion: nil)
    }

    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        dismiss(animated: true, completion: nil)
    }
}

This is a screenshot of what I get when the PickerView is presented:

1 Answers
Related