NSItemProvider always fails with loading a dropped file.

It seems to me that NSItemProvider doesn't work well in the latest Xcode 12 (macOS 10.15.6).

No matter what file types I'm trying to drop, I can never load them.
The error I'm getting:

Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.audio" UserInfo={NSLocalizedDescription=Cannot load representation of type public.audio}

And here's my code:
Code Block swift
// My SwiftUI View
Color.red
.onDrop(of: ["public.audio"], delegate: self)


Drop delegate:
Code Block swift
func performDrop(info: DropInfo) -> Bool {
let provider = info.itemProviders(for: ["public.audio"])[0]
provider.loadFileRepresentation(forTypeIdentifier: "public.audio") { (url, error) in
guard let url = url, error != nil else {
print(error!.localizedDescription)
return
}
...
}



I've tried this code with different type identifiers: audio, image, etc. All failed.
Anyone knows what's the issue?

Update


I managed to get it to work by using kUTTypeFileURL type identifier. I then decode the URL and load the file on my own.
I wonder, is this an expected behavior?
NSItemProvider always fails with loading a dropped file.
 
 
Q