I would like to implement an "Export" dialog using the .fileExporter()
view modifier. The following code works correctly, but the FileExporter's action label always says "Move", which is inappropriate for the context. I would like to change it to say "Export", "Save", "Save as", or anything semantically correct.
Button("Browse") {
showingExporter = true
}
.buttonStyle(.borderedProminent)
.fileExporter(
isPresented: $showingExporter,
document: document,
contentType: .data,
defaultFilename: suggestedFilename ?? fileUrl.pathComponents.last ?? "Untitled"
) { result in
switch result {
case .success(let url):
print("Saved to \(url)")
onSuccess()
case .failure(let error):
print(error.localizedDescription)
onError(error)
}
}
"document" is a custom FileDocument with a fileWrapper() method implemented like this:
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
return FileWrapper(regularFileWithContents: data)
}
This was tested on iOS 26 beta 3.