I am following Apple documentation https://developer.apple.com/documentation/coremotion/accessing_submersion_data
Created a new watchOS app with iOS companion app. Went into ContentView default code and added few lines as per documentation (also added authorisation for motion data and info.plist for WKBackgroundModes)
Copying whole code for context, but the one I added is the last at the end:`
import SwiftUI
import CoreMotion
//protocol SubmergeActionDelegate {
// func didSubmerge()
//
//}
struct GoUnderView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
}
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
GoUnderView()
}
}
func letsSinc () {
guard CMWaterSubmersionManager.waterSubmersionAvailable else {
return
}
let waterSubmersionManager = CMWaterSubmersionManager()
//Assign a delegate to receive events and update
waterSubmersionManager.delegate = self
}
Getting error: "Cannot find 'self' in scope; did you mean to use it in a type or extension context?"