79747117

Date: 2025-08-26 17:05:20
Score: 0.5
Natty:
Report link

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
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Grant Neufeld