@@ -94,10 +94,16 @@ struct DropModifierView<Content: SwiftUI.View>: SwiftUI.View {
9494 // • loadDataRepresentation → Data containing a UTF-8 "file://…" URL string
9595 // • loadItem → NSURL / URL object, or Data with the UTF-8 URL string
9696 // We try both paths and return whichever succeeds first.
97- if provider. hasItemConformingToTypeIdentifier ( UTType . fileURL. identifier) {
97+ // Folders dragged from Finder conform to public.folder, not public.file-url, so check both.
98+ let fileTypeID = provider. hasItemConformingToTypeIdentifier ( UTType . fileURL. identifier)
99+ ? UTType . fileURL. identifier
100+ : provider. hasItemConformingToTypeIdentifier ( UTType . folder. identifier)
101+ ? UTType . folder. identifier
102+ : nil
103+ if let fileTypeID {
98104 // Path 1: loadDataRepresentation (most reliable on macOS Finder drags)
99105 let viaData : String ? = await withCheckedContinuation { continuation in
100- provider. loadDataRepresentation ( forTypeIdentifier: UTType . fileURL . identifier ) { data, _ in
106+ provider. loadDataRepresentation ( forTypeIdentifier: fileTypeID ) { data, _ in
101107 guard let data else { continuation. resume ( returning: nil ) ; return }
102108 let urlString = String ( data: data, encoding: . utf8) ?
103109 . trimmingCharacters ( in: . whitespacesAndNewlines)
@@ -108,7 +114,7 @@ struct DropModifierView<Content: SwiftUI.View>: SwiftUI.View {
108114
109115 // Path 2: loadItem (returns NSURL on some systems, Data on others)
110116 return await withCheckedContinuation { continuation in
111- provider. loadItem ( forTypeIdentifier: UTType . fileURL . identifier , options: nil ) { item, _ in
117+ provider. loadItem ( forTypeIdentifier: fileTypeID , options: nil ) { item, _ in
112118 switch item {
113119 case let url as URL :
114120 continuation. resume ( returning: url. path)
0 commit comments