Error dismissing ImagePickerController

I am working on top of the ARKit Demo App. I created a button that opens up my photo library so that I could select a photo and store it in an UIImage variable. I am getting the error:


PhotoPicker discovery error: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}


after I select a photo from the Photo Library on my phone. I think the error occurs at the line, "self.dismiss(animated: false, completion: nil)", where self is the main ViewController.

I made sure to add the NSPhotoLibraryUsageDescription key in my Info.plist with a description.

did you find the solution?

Yes. You need to display the image picker as a popover, or else the ARSession gets interrupted.

I am getting this same issue... 😟 pretty sure this used to just work. There are plenty of tutorials online on this UIImagePickerController that is failed to work.


How to make it as "popover" and having this to work... Does not make sense why it is giving PhotoPicker discovery error: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}


Apple example needs to be updated to Swift, I think. It's so confusing.

The issue seems to be with this small thing....


WRONG

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {}

CORRECT

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {}

Have the same issue here, what you linked is the standard signature of the method, for recent code this doesn't solve anything unfortunatly

How did you display it as a popover???


I tried many things, but cant get it to work.

This helped me -- I had 'didFinishPickingIMAGE' instead of 'didFinishPickingMEDIA' ...

Any answer to this? I'm still getting this error and none of the answers here helped. Thanks.

I got the same error, I was using the info[UIImagePickerControllerImageURL] then I changed it to info[UIImagePickerControllerOriginalImage] as? UIImage , and it solved the issue for me. Hope it helps.

Tried all of these suggestions and still get the error in the debug log. Running Swift 4 XCode 9A235


What was suggest at various places

- some people said add @objc

- some people said add internal

- some people suggested adding _ and making sure using Any and not AnyObject

- some people said to use didFinishPickingImageWithInfo (this returns no image for me)

- some people said dismsss the picker, others said dismiss self, others said dismiss both

- some said add the 'Privacy... ' to plist (done)

- other suggestions here: https://stackoverflow.com/questions/44465904/photopicker-discovery-error-error-domain-pluginkit-code-13


I DID NOT get this issues in Swift 3 - previous xcode

But with Swift 4, I tried everying I saw suggested and I still get the following error


[discovery] errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}


The picker works fine and I DO end up selecting an image from photos, but I get this error message on exit, every time... Any suggestions?


my method


@objc internal func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {


imagePickerSelected = nil


if let editedImage = info["UIImagePickerControllerEditedImage"] as? UIImage {

imagePickerSelected = editedImage

} else if let originalImage = info["UIImagePickerControllerOriginalImage"] as? UIImage {

imagePickerSelected = originalImage

}


if imagePickerSelected != nil {

handleSelectedImage() // override in subclass to do somethign with the return image

}

picker.dismiss(animated: true, completion: nil) // mess of calling both dismiss to see if it helps - it does not

dismiss(animated: true, completion: nil)


}

I am getting the same exact error and my implementation is in Objective-C. Definitivilety not an issue related to type casting the info dictionary values returned in the delegate method: in obj-c the values of info dictionary are type casted as id in the method signature:


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info


I did as well take your same course of actions, but I'm still getting the error. Plus I've also added the code to request and handle the authorization status to access user's photo library.

I've also tried, as you did, to dismiss the image picker controller directly. No luck with that too.

I get the error either an image is selected from the library or not and always on dismissal of the image picker controller.


I've also tried to keep a strong reference to the image picker controller, still no luck with that too.

Marinly,


I have followed your exact same journey with the exact same results: no luck at all trying everything you did. I've looked at the StackOverflow posts too, and nothing has worked. XCode 9.0, iOS 11. Only additional weird behavior I see is that, when running in the simulator, there is a 10 - 18 second delay after selecting one of the five photos in the simulator's photo roll; I don't see this delay on an actual device.


I also tried adding the (I think new) Privacy setting in plist, "Media Library Usage". No workie.


I'll be monitoring this and StackOverlow to see if someone comes up with a solution.

Only this works for me:

1- From Xcode menu open: Product > Scheme > Edit Scheme

2- On your Environment Variables set OS_ACTIVITY_MODE in the value set disable

I fixed this issue, call function below into viewdidload or viewWillAppear or viewDidAppear to check permission for your app.

func checkPermission() {

let photoAuthorizationStatus = PHPhotoLibrary.authorizationStatus()

switch photoAuthorizationStatus {

case .authorized: print("Access is granted by user")

case .notDetermined:

PHPhotoLibrary.requestAuthorization({ (newStatus) in print("status is \(newStatus)") if newStatus == PHAuthorizationStatus.authorized { / do stuff here */ print("success") } })

case .restricted: / print("User do not have access to photo album.")

case .denied: / print("User has denied the permission.") } }
Error dismissing ImagePickerController
 
 
Q