I'm rebuilding the 2021 WWDC tutorial "Build a Workout App for Apple Watch" with the latest version of SwiftUI (August, 2022), and some of the old commands have been deprecated. Can someone help me rewrite the following to be compatible with iOS 16 and WatchOS 9?
List(workoutTypes) { workoutType in
NavigationLink(
workoutType.name,
destination: SessionPagingView(),
tag: workoutType,
selection: $workoutManager.selectedWorkout
)
}
I know that init(_:destination:tag:selection:) was deprecated in iOS 16. Apple recommends using NavigationLink(_:value:) instead inside a List within a NavigationStack or NavigationSplitView, but I cannot seem to get it to work on Xcode 14 beta 4.0.
Post
Replies
Boosts
Views
Activity
The small white dots are not displaying at the bottom of the paging view I've built using TabView and WatchKit for watchOS 9.0. These dots are normally used to indicate which tab view that the user is currently seeing so the user knows to swipe left or right to view a screen to the left or right of the current screen.
Also, unexpectedly the first state of the tab view (controls) displays rather than the second state (metrics) that was explicitly declared as the default state.
import SwiftUI
import WatchKit
struct SessionPagingView: View {
@State private var selection: Tab = .metrics
enum Tab {
case controls, metrics, nowPlaying
}
var body: some View {
TabView(selection: $selection) {
ControlsView().tag(Tab.controls)
MetricsView().tag(Tab.controls)
NowPlayingView().tag(Tab.nowPlaying
}
}
}
When running Xcode 15.0 beta, and targeting watchOS 10.0, I'm getting the following error message when I invoke the object. I am using the line import CoreLocation at the top of my ContentView.swift directly below the line import SwiftUI.
'CLMonitor' is unavailable in watchOS