Picker Error Message on Exit (encountered while discovering extensions: Error Domain=PlugInKit Code=13) With Swift 4 - Xcode 9

john picture john · Oct 6, 2017 · Viewed 12.3k times · Source

Similar to

PhotoPicker discovery error: Error Domain=PlugInKit Code=13

and also to

https://forums.developer.apple.com/thread/82105

BUT I have tried all of these suggestions and still get an error in the debug log. Running Swift 4 XCode 9A235

What was suggest at the various places was ...

  • 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)
  • added import Photos
  • added prior call to force PHPhotoLibrary.requestAuthorization() { (status) -> Void in ...

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 picker exit (cancel or select), every time...

Any suggestions how to stop the error message? Other than the list of things offered at the other two links (summarized above)

my method

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

    imageSelected = nil

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

    if  imageSelected != nil {
        handleSelectedImage()   // override in subclass to do something with the returned 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)
}

Answer

Antoine Richeux picture Antoine Richeux · Oct 9, 2017
  1. add the 'Privacy... ' to plist
  2. From Xcode menu open: Product > Scheme > Edit Scheme > On your Environment Variables set OS_ACTIVITY_MODE in the value set disable

see in mc-system-group-container-and-mc-reading-from-public-effective-user-settings-err

Work's fine for me

EDIT

if it's can help below my code (working with xcode 9)

if libraryAuthorization == .authorized {
        let imagePicker = UIImagePickerController()
        imagePicker.delegate = self
        imagePicker.sourceType = UIImagePickerControllerSourceType.photoLibrary
        imagePicker.allowsEditing = false
        imagePicker.view.tag = button.tag
        self.present(imagePicker, animated: true, completion: nil)
    }
}

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    if let pickerImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
        photoContainer.addImageToButton(pickerImage, buttonTag: picker.view.tag)
        dismiss(animated: true)
    }
}