Haptic Engine Unavailable...?

Hello everyone. I'm running into a weird error.


I cannot compile my code when I try and utilize the methods playHaptic(<WKHapticType>) and CMSensorRecorder.recordAccelerometerForDuration(<NSTimeInterval>).


Both of these result in errors such as "playHaptic is unavailable" or "CMSensorRecorder does not have a member for recordAccelerometerForDuration" and are both new changes in watchOS 2.0...


This makes me think that I'm missing some integration in terms of my Xcode setup and software installation, because they're both new changes implemented in the latest software.


Please help. I'm running the latest betas on my iPhone, Apple Watch, and MacBook, as well as the latest beta of Xcode.


Thanks much,

Josh

playHaptic is a method of WKInterfaceDevice class so you have to call it this way:

WKInterfaceDevice.currentDevice().playHaptic(<WKHapticType>)


In order to use

CMSensorRecorder.recordAccelerometerForDuration(<NSTimeInterval>)

you have to import CoreMotion and add CoreMotion.framework to your extension.

import CoreMotion

That's just it - I have already done all that. It seemingly doesn't make a difference.

Are you sure your project is for watchOS 2? those API aren't available in watchOS 1 apps.

How do I verify that? I think that might be my problem.

Select your WatchKit Extension from Targets, go to Build Settings and search for watchOS Deployment Target. (It should be 2.0).

If it's wrong, try to "Validate Settings..." in Xcode 7. If it doesn't work, you have to add a new Target (watchOS Application).

Just did that. The dialog list was blank, but I hit "Perform Changes" anyways. Running the app again results in "No such module Core Motion"

It seems you have a corrupted Xcode project.

Maybe the simplest way to fix this is to add a new Target, as I say in my previous post, and copy-paste all your code...

Same issue here. Nothing seems to solve it. Everything is using watchOS2


playHaptic is unavailable: not available on iOS

WKHapticTypeDirectionUp is unavailable: not available on iOS.


Code in WatchOS-2 Extension:

WKInterfaceDevice *dev = [WKInterfaceDevice currentDevice];

[dev playHaptic:WKHapticTypeDirectionUp];

I dont get it.

XCode 7.1.1 (7B1005)

Edit: Got this working. The .m I was trying it in was corrupt or something. I made a new one and it worked.

Haptic Engine Unavailable...?
 
 
Q