I'm testing an app I'm developing on a real device: Watch Series 7 running watchOS 9.0.2. I have a WKExtensionDelegateAdaptor variable in the @main struct. I'm trying to print the name of the watch as found in Settings > General > About > Name. However, all I get is "Apple Watch" even though the name of the watch is "My Watch 7." I'm not sure if this has changed but not documented. Code is below:
import SwiftUI
@main
struct TheApp: App {
@WKExtensionDelegateAdaptor private var extensionDelegate: ExtensionDelegate
var body: some Scene {
WindowGroup {
HomeView()
}
}
}
import WatchKit
class ExtensionDelegate: WKExtensionDelegate {
func applicationDidFinishLaunching() {
print("Device name: \(WKInterfaceDevice.current().name)")
}
}
This is expected behaviour in watchOS 9 and newer. The documentation has now been updated.