I'm making some maintenance on my iOS app with SwiftUI. One feature of this app is open the Files app (using fileimporter) to select a file, import it and make some analysis to it. This has been working ok so far.
But today I've suddenly found out that fileimporter it's not working properly and I'm pretty sure it was working ok some weeks ago and I haven't made any change in the app since then.
I'm thinking if it's a problem of any ios update.
My code to open fileimporter is this:
import SwiftUI
struct AnalyseFileView: View {
@ObservedObject var observedModel: AnalyseFileViewAdapter
@State var hasToOpenFilesApp = false
@State var isViewVisible: Bool = false
init(observedModel: AnalyseFileViewAdapter) {
self.observedModel = observedModel
}
var body: some View {
NavigationView {
ZStack {
VStack(alignment: .leading, spacing: 0) {
ScrollView {
VStack(alignment: .center, spacing: 0) {
...
CustomButton(title: "Open files app") {
hasToOpenFilesApp = true
}.fileImporter(isPresented: $hasToOpenFilesApp, allowedContentTypes: [.text, .zip, .gzip, .vCard]) { result in
switch result {
case .success(let url):
print(url)
manageSelectedFile(url: url)
case .failure(let error):
print(error)
}
}
.buttonStyle(CustomButtonStyle(style: .terciary, size: .large, isFullWidth: true))
.padding([.leading, .trailing], 25)
.padding(.bottom, 24)
...
}
}
}
}
.background(Color("primary4_primary3"))
.navigationBarHidden(true)
.onAppear {
isViewVisible = true
startView()
}
.onAppCameToForeground {
if isViewVisible {
startView()
}
}
.onDisappear {
isViewVisible = false
}
}
}
private func startView() {
observedModel.presenter?.viewWillAppear()
}
private func manageSelectedFile(url: URL) {
observedModel.selectedFile = url
guard url.startAccessingSecurityScopedResource() else { return }
observedModel.presenter?.manageFilePicked(url: url)
url.stopAccessingSecurityScopedResource()
}
}
With my iPhones 16.5 and 16.2 Files app is open this way:
As you can see there is only the Recents option and there is no way to get the Browse button to go to iCloud, Dropbox, My Device, etc... Search bar is working, it finds my files in those locations but it's more friendly to have the browse button.
What could have happened? I'm pretty sure this browse button was being shown a couple of weeks ago.
Just in case, I've just tested in an iPhone 14 and iPhone 15 and Files app shows the correct button: