UIDocumentPickerViewController for local iOS files

I have an app that recursively copies a set of files/folders from its resource to the .documentDirectory/.userDomainMask directory.

I know the files are successfully copied because I can see the files/folders in the Finder in the respective simulator directory.

However when I try to show them in my SwiftUI app using the UIDocumentPickerViewController the On My iPhone list is totally empty! Even if I specify the documents folder URL as the starting directoryURL it still comes up empty.

Am I missing something or is this not possible?

OK, some digging on StackOverflow shows that "On My iPhone" is indeed a separate area called "File Provider Storage". You can add files to this area by dragging over the simulator. I don't think there is any way for a normal app to copy to this folder.

So what I wound up doing for my app is to have my own picker for "built-in" files and have a separate command to use the UIDocumentPickerViewController to pick files that are not internal to the app.

UIDocumentPickerViewController for local iOS files
 
 
Q