In sample code Building a Great Mac App with SwiftUI | Apple Developer Documentation, selecting Export… from the menu does nothing.
It looks like .fileExporter
needs to be applied to the the enclosing Section
instead of the Button
.
CommandGroup(replacing: .importExport) {
Section {
Button("Export…") {
isShowingExportDialog = true
}
}
// Doesn't work when it is applied to the button,
// but works when applied to the section
.fileExporter(
isPresented: $isShowingExportDialog, document: store,
contentType: Store.readableContentTypes.first!) { result in
}
}