You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Swift中UIImagePickerController选图时出现PlugInKit Code13错误求助

Fixing the PlugInKit Code=13 "query cancelled" Error with UIImagePickerController

Hey there! Let's break down what's going on with that error you're seeing in the console when using UIImagePickerController.

First off, let's get the big relief out of the way: this error is almost always harmless system-level noise. The PlugInKit Code=13 message comes from iOS's internal extension discovery process getting cancelled (usually because your picker dismissed before it finished looking for extensions), and it doesn't actually break your image selection functionality. Thousands of developers run into this, and it's not a sign of broken code on your end.

That said, if you want to confirm your implementation is solid, or just want to clean up the console, here are some checks and fixes:

1. Verify Privacy Permissions Are Configured

Even though this error isn't permission-related, missing required privacy descriptions can cause other issues with UIImagePickerController. Make sure your Info.plist has these entries:

  • For photo library access: Add NSPhotoLibraryUsageDescription with a clear reason (e.g., "Need access to your photo library to select images")
  • For camera access (if you're using it): Add NSCameraUsageDescription with a similar reason

2. Clean Up Your Picker Delegate Code

Your existing delegate method snippet is incomplete—let's make sure it's properly implemented (including handling the cancel case):

// Use the modern InfoKey enum instead of raw Strings for better type safety
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    // Safely unwrap the image instead of force-casting to avoid crashes
    guard let selectedImage = info[.originalImage] as? UIImage else {
        picker.dismiss(animated: true)
        return
    }
    
    imagePicked = selectedImage
    // Always make sure to dismiss the picker properly
    picker.dismiss(animated: true) {
        // Optional: Add code here to update your UI after the image is selected
    }
}

// Don't forget to handle the cancel action
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
    picker.dismiss(animated: true)
}

3. Hide the System Log (If You Want)

If you're annoyed by the log cluttering your console, you can suppress it by adding an environment variable in Xcode:

  • Go to Product > Scheme > Edit Scheme
  • Select the Run tab, then switch to the Arguments section
  • Under Environment Variables, click the + button
  • Add a new entry with:
    • Key: OS_ACTIVITY_MODE
    • Value: disable

Note: This will turn off all system logs, so you might want to toggle it off when debugging other system-related issues.

Final Note

Again, that PlugInKit error is just iOS chattering about internal processes—it won't affect your app's functionality. As long as your image picker works as expected (selects images and dismisses properly), you can safely ignore it.

内容的提问来源于stack exchange,提问作者Fabian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:06:08