Image fails to open via Drag and Drop on iOS

I've got a SwiftUI app with the onDrop method on my View like this:

Code Block
.onDrop(of: [.image], delegate: myController)



In an extension of my controller I conform to the DropDelegate and implement performDrop(info:)

Here's my implementation:

Code Block
guard info.hasItemsConforming(to: [.image]) else { return false }
let items: [NSItemProvider] = info.itemProviders(for: [.image])
guard let item: NSItemProvider = items.first else { return false }
guard item.canLoadObject(ofClass: MPImage.self) else { return false }
item.loadObject(ofClass: MPImage.self) { (reading, error) in
guard error == nil else { return }
guard let image: MPImage = reading as? MPImage else { return }
self.didLoad(image: image)
}


The code compiles fine on iOS (tho not on macOS, see link)
https://developer.apple.com/forums/thread/653934

So when I run the app on iOS, and drag an image from Photos and drop it on my app I get the following error:

MyApp perform drop failed: Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.jpeg" UserInfo={NSLocalizedDescription=Cannot load representation of type public.jpeg, NSUnderlyingError=0x283fa15f0 {Error Domain=NSCocoaErrorDomain Code=260 "The file “DAE533E7-2918-465E-9F3C-502B8DEC78BA.jpeg” couldn’t be opened because there is no such file." UserInfo={NSURL=file:///var/tmp/com.apple.DragUI.druid/.com.apple.DragUI.BDfAeP/DAE533E7-2918-465E-9F3C-502B8DEC78BA.jpeg, NSFilePath=/var/tmp/com.apple.DragUI.druid/.com.apple.DragUI.BDfAeP/DAE533E7-2918-465E-9F3C-502B8DEC78BA.jpeg, NSUnderlyingError=0x283f4b8a0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}}}

This appears to be a bug with the iOS Simulator. I'm also having the same problem when sharing one of the default images in the iOS Simulator to my app in iOS 14.0 Beta 3.

Willing to bet the image you're having trouble with is from the Photos app, dated March 30, 2018. It's the image with the pink and purple flowers. If you open the Photos app, and try to copy that image from the share sheet, you'll get the error, "Unable to Share: There was an error while preparing to share. Please try again later." This strongly suggests that this image is corrupted somehow.

I'd file a Radar and move on.
I get the error in an alert in the Files app when I drop a jpeg in a folder. (iOS 14.0 Release)
Image fails to open via Drag and Drop on iOS
 
 
Q