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.
Post
Replies
Boosts
Views
Activity
Also on MacBook Pro M1 Pro 14.4.1, XCode 15.3, iPhone 14 Pro 17.4.1, Apple Watch 10.4. Also have tried all resets, restores, clean install of watchOS 3x and I cannot get XCode to see the watch at all.
In Devices and Simulators, I can only see iPhone. No Apple Watch is even present.
In my macOS Console, I can see the Device listed, but I cannot read any messages due to Warning Symbol. I suspect it is waiting for "Trust This Computer" prompt which never shows up on Apple Watch.