Shared Extension Post photo: Failed to determine whether URL is managed by a file provider

Viewed 968

I am trying to implement a share extension which post an image from PhotoLibrary to my App. But I keeps encountering this error:

2019-01-13 10:57:14.272148-0800 deegeu-swift-share-extensions-image-share[11664:1341769] 
    [default] [ERROR] Failed to determine whether URL /var/mobile/Media/PhotoData/OutgoingTemp/F49538B5-7AD5-46EA-BC0E-CEC304DEEB64/IMG_4293.JPG (s) 
    is managed by a file provider.

This is the exact project source code I am trying with: Github Project And this is the step I followed closely: Video Tutorial

My system information: iOS 12.1, iPhone 6s.

I have updated project information such as App Group, developer profile to my own in Xcode.

What could be the cause?

2 Answers

Please try running in a real device.

I tried running the code from the repository in a simulator and encountered the error mentioned. But when I ran the app in a real device I was able to achieve the desired functionality as shown in the video.

Please note that when running in the device, you will need to set the correct bundle identifier, App group name etc.

You will also need to change the App group name references in RedViewController, BlueViewController and ShareViewController swift files.

Once done please run the main app as well as the extension(selecting the main app when asked for by Xcode) and you should be up and running

The error that is printing, i think, is comming from the Photos app. Solution that worked for me is:

  itemProvider.loadItem(forTypeIdentifier: kUTTypePNG as String) { [unowned self] (imageData, error) in
                        if let item = imageData as? NSURL {
                            let data = NSData(contentsOf : item as URL)
                            let image = UIImage(data : data! as Data)
                            print(image)
                        } else {
                            if let item = imageData as? UIImage{
                                print(item)
                            }
                        }
                    }

error is stil there but i created the UIImage instance that i needed. First condition is for sharing from Photos app, otherwise i'm getting the correct image.

Related