After tinkering the last few weeks trying to get this to work myself, I discovered that toolbar items in WatchOS require the:
.navigationTitle("Navigation")
in a very specific place. In your code, it should look like this:
var body: some View {
NavigationView {
ScrollView {
VStack(alignment: .leading) {
ForEach(0..<100) {
Text("Row \($0)")
}
}
.navigationTitle("Navigation")}
.toolbar {
ToolbarItem(placement: .primaryAction) {
Button("Settings") {}
}
}
}
}
}
Navigation Titles do have to be attached to the inner view, and for some reason the Toolbar Item won't be automatically hidden unless the navigationTitle is present. I'm confident this should work for you since we have similar view hierarchy in our code.
A sidenote: The toolbar behavior doesn't seem to render properly in the canvas in XCode 12.5.1. I had to build and run the app directly on my Apple Watch in order to see the behavior. When the debugger launches, the toolbar will not be hidden. But when the debugger is detached from the watch and the app is running on its own, the behavior is as expected from the HIG.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: