If you like to switch from deeper views you may like to use @AppStorage or @SceenStorage to save the selected tab.
that could look like:
@SceneStorage("selectedView") var selectedView: String?
var body: some View {
TabView (selection: $selectedView){
NavigationView {
TimerView()
}
.tag(TimerView.tag)
.tabItem {
Image(systemName: "stopwatch.fill")
Text("Timer")
}...
And then anywhere in deeper views:
Button(action: {
selectedView = TimerView.tag
}) {
Text("Switch Tab")
}
TimerView.tag in example is just constant to do not use strings across the app:
static let tag: String? = "Timer"
SwiftUI will take care of Tab switching as soon as you will update @SceneStorage value and it will save last opened tab in the app as well.