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.

Replies

I'm having same issue: https://stackoverflow.com/questions/46941499/swift-4-error-using-firebase-in-simulator-trying-to-upload-image-from-photo-libr


Assuming this is an xcode bug and will be fixed soon.....

This is how I fixed it:


func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        if let pickedImage = info[UIImagePickerControllerEditedImage] as? UIImage {
           
            ........
           
        }
        dismiss(animated: true, completion: nil)
    }

I am getting the same issue, it persists with Xcode 9.1 beta the only thing I have not tried is changing it to a popover. Will be trying that in a few..

Occured to me as well using 9.1. Strangely my code worked fine then I decided to add a UIImage extension . It worked with extension as well but when I decided to erase the extension from my code the the error occured. Then nothing helped . Tried to reset the simulator basically but it did not help.

What's the bug number?

After more tests it turned out that the message dont really affect the code. It is just an Xcode bug but my code performs OK.

nothing to do as far as I can tell with changing to popover, I still get the same cryptic message when the picker is changed to popover.

yep I think you are right, I have another issue in my app that is causing it to wedge, the Xcode warning appears to be benign.

I found this solution. we got this error due to these two reason which is mentioned below.



1. First we need to call this method in viewWillAppear for authorization



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.") } }







2. Method Calling of didFinishPickingMediaWithInfo

***Wrong:***



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

}



Right



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

}



I hope this solution will help you out to resolve this error.

If it works for you don't forget to mark it's as a correct, so this will help to other to find the correct way.

Has anyone identified a fix or a workaround for this? I've tried the .popover fix and the (_picker) fix, and the @objc/internal fix, all to no avail. The program isn't entering my imagePickerController() function.

It has something to do with the rating control. I changed the variable in meal to 1 instead of "rating" and it loaded. Didn't load the rating, but at least the meal loaded into the table view. So, in your imagePickerController function in MealViewController.swift, at the bottom line, enter: meal = Meal(name: name, photo: photo, rating: 1).

Its Working fine for me.

I have similar warning since I installed OSX 10.13.1.

That's an OSX App, XCode 9.2.

No use of photokit, nor ARKit in the app.


From the message : errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}

I could not figure out which extension was concerned.

This fix my error, thank you!

Hello Everyone, i tried many ways to fix but got the same error. After doing everything this fixed my problem.


From Xcode menu open:

1. <Product> - then select - < Scheme > - then select - < Edit Scheme >


2. Goto Environment Variables and set OS_ACTIVITY_MODE and in the value set " disable ".

OR

If you dont have this flag please add OS_ACTIVITY_MODE and set the value to " disable ".



I hope it helps.