I have a SwiftUI/Catalyst app that shall receive audio/video files per drag/drop.
On a certain view I have the fowling modifier, which accepts the specified media files.
.onDrop(of: ["public.movie","public.audio"], isTargeted: nil, perform: { providers in
print(providers.first)
let _ = providers.first?.loadObject(ofClass: URL.self, completionHandler: { (url, _) in
print(url)
})
return true
})
When I drop a file, the returned provider prints
Optional(<NSItemProvider: 0x600002ae4b60> {types = ( "com.apple.m4a-audio", "com.apple.finder.node" )})
which looks OK. However when I try to determine the URL of the dropped file I always get nil.
What is wrong with this code ?