Both the .fileImporter function (in SwiftUI) and the UIDocumentPickerViewController are shown as intended, but the do not show any contents. Instead it says: "Content not available" on the Shared and Recent Icons and "My iPhone is empty" on the Browse Icon.
How did I implement them? .fileImporter:
var body: some View {
VStack {
// ...
}.padding(.horizontal, 25)
.fileImporter(isPresented: $selectingFile, allowedContentTypes: [.item], onCompletion: { _ in })
}
UIDocumentPickerViewController:
struct ImportDocumentView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> some UIViewController {
let controller = UIDocumentPickerViewController(forOpeningContentTypes: [.item])
controller.allowsMultipleSelection = false
return controller
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
}
What I thought could be the problems:
- Wrong UTType -> tried a load of different options there; none helped.
- Emulator Problem -> I don't have an iPhone to test this. I need to make it work in the emulator. Other people had problems with the emulator, but not showing any data was not one of them.
- Access Permissions -> In my understanding I should at least have access to the app specific folder, but even that is not showing. I also tried to set "NSFileProviderDomainAccess" in Info.plist, but that didn't work either. (I might have done something wrong in the process though)