I'm building an app to manage and edit some files. To do that, I want to open the files in place dropping them into a view. I cannot find a way to obtain the file URL after the drop operation. If I constrain the file types to .fileURL, the drop frame doesn't activate. If I use .data, I get the file and not the path, which is what I want.
Any way to do this the SwiftUI way?
.onDrop(of: [.fileURL], isTargeted: $dragOver) { providers -> Bool in
providers.first?.loadDataRepresentation(forTypeIdentifier: "public.file-url", completionHandler: { (data, error) in
if let data = data {
print(data.description)
}
})
return true
}