SwiftUI `fileImporter` ViewModifier not working on iOS 15

Originator:b.stillitano95
Number:rdar://FB9997895 Date Originated:
Status: Resolved:
Product:SwiftUI Product Version:
Classification: Reproducible:Yes
 
I'm seeing some weird behaviour with the fileImporter modifier on my iOS app. When running this View code on an iPhone running iOS >= 16, it runs fine, the document picker presents itself and passes back the result, no issues.

```
struct SomeView: View {
    @State private var importingFile = false

    var body: some View {
        List {
            Section(header: Text("Header"), footer: Text("Footer") {
                Text("Tap to open")
                .onTapGesture {
                    importingFile = true
                }.fileImporter(isPresented: $importingFile, allowedContentTypes: [.pdf]) { result in
                    didImportFile(withResult: result)
                }
            }
        }
    }

    func didImportFile(withResult result: Result<URL, Error>) {
        print("Do something with result")
    }
}
```

The problem occurs when running on iOS 15 (possibly 14, unable to test at the moment), wherein, nothing happens at all. No document picker is presented.

Looking at the official documentation here https://developer.apple.com/documentation/swiftui/view/fileimporter(ispresented:allowedcontenttypes:allowsmultipleselection:oncompletion:), this API is marked as iOS 14 compatible and I'm definitely not adding an #if available checks so I know it's not an api compatibility issue.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!