Search code examples
swiftuiuttypeswiftui-fileimporter

Using fileImporter to import cloud folders


I'm using fileImporter to let the user select a folder:

.fileImporter(
    isPresented: viewStore.binding(\.$fileImporterPresented),
    allowedContentTypes: [.folder],
    allowsMultipleSelection: false
) { resources in
    // Do something
}

On macOS 13 (SwiftUI, not Catalyst) everything works as expected.

On iOS 16.1 it shows an open action for a folder but I cannot access Dropbox.

When I add additional allowedContentTypes like .directory, or .volume then Dropbox is no longer greyed out but it is also no longer possible to select a folder:

Selecting a folder seems to only work when the only allowedContentType is .folder.

How do I configure fileImporter to select a folder on an iOS external cloud storage provider?


Solution

  • The problem seems to be with Dropbox not implementing NSExtensionFileProviderSupportsPickingFolders. That's why it's greyed out in the fileImporter but also in the UIDocumentPickerViewController.

    More information: https://stackoverflow.com/a/71379422/225833