Recently, I have been working on an app that is centered around opening files on iOS. Opening files is something we have been able to do on iOS for several years now and the concept is pretty simple. While working on this app I ran into a bug in iOS 13.
Users can no longer select multiple folders with UIDocumentPickerViewController
in iOS 13. This is obviously a problem when your app’s functionality is heavily reliant on opening an arbitrary number of files and folders that users select.
I have a very simple sample project that demonstrates the regression.
The code is very simple:
let documentPicker = UIDocumentPickerViewController(documentTypes: [kUTTypeDirectory as String], in: .open)
documentPicker.allowsMultipleSelection = true
present(documentPicker, animated: true, completion: nil)
It just creates a document picker by specifying the UTIs we allow the user to select. I have not found a different UTI or combination of UTIs that create a UIDocumentPickerViewController
that allows user to select multiple folders.
Side Note: Choosing a single folder is still supported if you use the UTI of
kUTTypeFolder
instead ofkUTTypeDirectory
. The curious thing is that a completely different view is presented when creating the document picker view controller with just thekUTTypeFolder
UTI. This view does not have the “select” functionality that would allow multiple folder selection.
Reproduction Steps
Prerequisites
Set up two simulators, one iOS 12.x and one iOS 13.x, and sign in to an iCloud account. Make sure that iCloud account has two folders in iCloud drive.
iOS 12
- Run the sample app.
- Tap the button.
- Tap “select” to enter selection mode.
- Verify you are able to select the folders.
iOS 13
- Run the sample app.
- Tap the button.
- Tap “select” to enter selection mode.
- Verify you are NOT able to select the folders.
With this simple project you can see that selecting multiple folders at a time was supported on iOS 12 and is no longer possible with the exact same code on iOS 13. I have not been able to find any documentation stating this change was intentional.
Work-Arounds?
Quick refresher: There are a couple supported ways to let users select a document and do something with it.
UIDocumentPickerViewController
UIDocumentPickerViewController
is a view controller that your app can use to let a user import, export, open, or move a file/document. It’s a pretty simple idea. You present this view controller when the user needs to move a file in/out of your app.
UIDocumentBrowserViewController
UIDocumentBrowserViewController
is a view controller for browsing and performing actions on documents. It is designed to be the root view controller in a document-based app (like Pages, Numbers, Keynote, etc.). UIDocumentBrowserViewController
is designed to be the view controller you design/build your entire app around. You start at the document browser and only navigate away when a user selects a document.
So, we have already addressed the fact that UIDocumentPickerViewController
does not work for a situation where you need to open/import more than one folder at a time.
Open folders one at a time
The first solution is more of a change in your app navigation than a functional replacement. You could create a flow where users would open one folder at a time until they have opened all of folders they want. This only works if you know that the user needs/wants to open a folder before presenting the UIDocumentPickerViewController
.
[Mis]Use UIDocumentBrowserViewController
The best work-around I have found so far is to present a UIDocumentBrowserViewController
modally, even though the documentation explicitily says not to do this. It seems to work well even though it is not intended to be used as a document picker.
Bug Report
I filed a bug in Feedback Assistant on December 9, 2019. It is still “Open” but has a resolution of “Investigation complete - Works as currently designed”. I don’t know exactly what that status means, but it sounds like Apple thinks this isn’t an issue and will not fix it. (But if that is the case then why not mark the issue as “Closed”?) I just find it really hard to belive that it “works as currently designed” given that opening multiple folders at a time was possible in iOS 12, and no longer seems to be possible in iOS 13 without misusing UIDocumentBrowserViewController
.
In hindsight, my initial bug report could have been a little more detailed, though I thought it was pretty clear from the sample project that the behavior in iOS 13 was different than iOS 12. I hope this blog post will help provide any missing details and get the attention of someone at Apple so this gets a second look.
Feedback Assistant: https://feedbackassistant.apple.com/feedback/7486859
Content of the bug report: https://github.com/addisonwebb/FB7486859/blob/master/README.md
Open Radar: https://openradar.appspot.com/radar?id=4954820121198592
Conclusion
If you think this is something that should be fixed, please take a few minutes to dupe FB7486859.
If you spot a problem in my sample code, or know of a way to reenable multiple folder selection in iOS 13’s UIDocumentPickerViewController
please let me know!
Links
Sample Project: https://github.com/addisonwebb/FB7486859