28 Replies
      Latest reply: Dec 9, 2017 2:26 PM by Claude31 RSS
      andreasdias9 Level 1 Level 1 (0 points)

        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.


        • Re: Error dismissing ImagePickerController
          a4anton Level 1 Level 1 (0 points)

          did you find the solution?

          • Re: Error dismissing ImagePickerController
            YojimboMaster Level 1 Level 1 (0 points)

            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]) {}

            • Re: Error dismissing ImagePickerController
              Riadhoq Level 1 Level 1 (0 points)

              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.

              • Re: Error dismissing ImagePickerController
                marinly Level 1 Level 1 (0 points)

                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)

                 

                    }

                  • Re: Error dismissing ImagePickerController
                    vale_mac Level 1 Level 1 (0 points)

                    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.

                    • Re: Error dismissing ImagePickerController
                      rapdevpro Level 1 Level 1 (0 points)

                      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.

                    • Re: Error dismissing ImagePickerController
                      desenvolvedor Level 1 Level 1 (0 points)

                      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

                      • Re: Error dismissing ImagePickerController
                        thanhnc85 Level 1 Level 1 (0 points)

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

                        • Re: Error dismissing ImagePickerController
                          cAgha Level 1 Level 1 (0 points)

                          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)
                              }
                          
                          • Re: Error dismissing ImagePickerController
                            tylernol Level 1 Level 1 (0 points)

                            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..

                            • Re: Error dismissing ImagePickerController
                              dkramf Level 1 Level 1 (0 points)

                              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. 

                              • Re: Error dismissing ImagePickerController
                                tylernol Level 1 Level 1 (0 points)

                                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.

                                • Re: Error dismissing ImagePickerController
                                  akashjaiswal23 Level 1 Level 1 (0 points)

                                  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.

                                  • Re: Error dismissing ImagePickerController
                                    maxAlces Level 1 Level 1 (0 points)

                                    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.

                                      • Re: Error dismissing ImagePickerController
                                        jhb Level 1 Level 1 (0 points)

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