UIDocumentPickerViewController for outside-the-sandboxed directories ?

In my app, users will usually want automatic syncing of a set of many hundreds of files with several members of a team, so mere personal iCloud just won't cut it. In my soon-to-be-released Mac app, that was easy. I just let the user pick a directory and use bookmarked security scoped urls, and if they pick a dropbox or google drive -synch'ed folder, fine; it just works. It even detects changes and animates my summary details of the set of files in my UI live.


However, on iOS, I'm not sure whether UIDocumentPickerViewController can do what I want. When I initialize it like so:


UIDocumentPickerViewController(documentTypes: [kUTTypeFolder as String, kUTTypeDirectory as String], in:.open)


and run it, but when I delect a directory, the button isn't enabled to proceed.


Can someone tell me IF UIDocumentPickerViewController is suppossed to be able to handle getting a book-markable url to a directory outside my sandbox?

Replies

Per WWDC 2019 slides, I'm using the following code to let the user select a folder so that my app can process the contents of the folder. But, the delegate is never called when the user taps on a folder.


let documentPicker = UIDocumentPickerViewController(documentTypes: [String(kUTTypeFolder)],  in: .open)
    documentPicker.delegate = self
    documentPicker.allowsMultipleSelection = true
    present(documentPicker, animated: true) {
        print("done presenting")
    }

According to this:

https://developer.apple.com/documentation/uikit/view_controllers/providing_access_to_directories

iOS 13 adds the ability of UIDocumentPickerViewController to select a directory, including directories from 3rd party file providers, which is exacly what I'm looking for.

However, doing this in UIKitForMac in Xcode 11 beta 3 / Catalina beta 3 does not work (the Open button merely opens the selected folder, and does not import it). I'm not able to test in iPad simulator, because there don't seem to be any folders...

@benspratling4, did you manage to get this working? I can't get past the third party cloud providers being greyed out. I can only navigate into the iCloud Drive folder from the picker.