SwiftUI only being partially cross-platform, it is different on macOS (.directory
) vs. iOS (.folder
).
Here’s a fileImporter
call from one of my projects where I want the user to select a directory to save files in:
#if os(macOS)
.fileImporter(
isPresented: self.$showFileDialog,
allowedContentTypes: [.directory],
onCompletion: self.saveWithNewDirectory
)
#else
.fileImporter(
isPresented: self.$showFileDialog,
allowedContentTypes: [.folder],
onCompletion: self.saveWithNewDirectory
)
#endif