Cannot find 'UINotificationFeedbackGenerator' in scope - Getting this error with Xcode 14.3 watchOS project.

Cannot find 'UINotificationFeedbackGenerator' in scope - Getting this error with Xcode 14.3 watchOS project.

Using SwiftUI and Xcode 14.3.1

Already imported UIKit

import UIKit

        let notificationGen  = UINotificationFeedbackGenerator()

Similar issue with WKInterfaceDevice also. try WKInterfaceDevice.current().play(.click) Error: Cannot find 'WKInterfaceDevice' in scope

Replies

UIKit is not public API on watchOS, and UINotificationFeedbackGenerator is not available on watchOS. https://developer.apple.com/documentation/uikit/uinotificationfeedbackgenerator/

It's hard to know what your issue is with WKIntefaceDevice without context.