Drag file from app to Finder on macOS

Is it possible under macOS to drag a file from an app into the Finder? 

For example, I want to drag a CSV file from the app to the Finder, but the following code does not work.

static var transferRepresentation: some TransferRepresentation {
        FileRepresentation(exportedContentType: .commaSeparatedText) {_ in
            SentTransferredFile(Bundle.main.url(forResource: "Demo", withExtension: "csv")!)
        }
}

And I changed the exportedContentType to ".fileUrl", ".url" and ".data" but the code still does not work.

I have the same doubt, did you manage to get it to export to a file?

This seems like a bug, it works fine on iOS but macOS it doesn't work

Please file a bug and post the feedback ID.

The only workaround for now is to use ProxyRepresentation

Note: ProxyRepresentation has a different purpose to serve as a proxy, but since the bug that is the only workaround I can think of.

Same issue. My workaround for now:

static var transferRepresentation: some TransferRepresentation {
 ProxyRepresentation { item in
            Bundle.main.url(forResource: "Demo", withExtension: "csv")!
        }
}

I've been told that this is a bug. I've filed a report: FB11992448

Please do the same so it gets enough attention and will be fixed as soon as possible.

I think you misunderstand the purpose of FileRepresentation. I know I did. It is not for dragging file objects, it is for storing drag data in a file rather than memory.

This works for me on macOS for dragging between apps. It's missing something to work with the Finder though.

DataRepresentation(exportedContentType: .fileURL) { item in
            let url = URL(string:"test")!
            return url.absoluteString.data(using: .utf8)!
}
Drag file from app to Finder on macOS
 
 
Q