I'm writing an app in SwiftUI on macOS 13.1, and want to drag image from my app to Desktop/Finder. Referred to this post, I gave .onDrag a try with following code. But the dragging don't have any reaction no matter how and where I drag it.
struct ContentView: View { @State var image: NSImage = NSImage(imageLiteralResourceName: "demoImage") var body: some View { Image(nsImage: image) .resizable() .scaledToFit() .frame(width: 200, height: 200) .onDrag { NSItemProvider(item: image.tiffRepresentation as NSSecureCoding?, typeIdentifier: UTType.image.identifier) } } } If I change typeIdentifier from UTType.image.identifier to UTType.tiff.identifier, the image in my app can at least successfully be dragged to Apple Pages, but it still fails when dragging to Desktop/Finder.
Then I tried to replace .onDrag with .draggable(image.tiffRepresentation ?? Data()), but the outcome is in the same.
How can I solve this?
