Help command in SwiftUI Mac project
Default SwiftUI on the Mac project includes the default Help command. But there’s a little problem. It also adds the default help menu. I recommend implementing the menu or at least removing it from your app. Otherwise, it gives the impression of an unfinished app.
Luckily it is just a few lines of code and you can link to your website.
struct HelpMenu: View {
var body: some View {
Group {
Link("Your App Website", destination: URL(
string: "[www.your-site.com/your-app/](https://www.your-site.com/your-app/)")!)
// Place other Help menu items here.
}
}
}
.commands {
CommandGroup(replacing: .help) {
HelpMenu()
}
}
Linking to a website is the easiest option. If you want to do better, some Mac apps provide documentation in the form of a little book, accessible offline. Find original code and information about help books on the Swift Dev Journal.
This post wouldn’t be possible without the work which went into LinkEdit. It describes one of the many features and improvements included in recent 1.3 major update.