WatchKit / Healthkit - 无法创建游泳HKWorkout会议

时间:2016-10-20 05:42:04

标签: watchkit health-kit

我按如下方式设置HKWorkout会话的配置:

self.configuration = [[HKWorkoutConfiguration alloc] init];
self.configuration.activityType = HKWorkoutActivityTypeSwimming;
self.configuration.locationType = HKWorkoutSessionLocationTypeOutdoor;
self.configuration.swimmingLocationType = HKWorkoutSwimmingLocationTypeOpenWater;

HKWorkoutSession *session = [[HKWorkoutSession alloc] initWithConfiguration:self.configuration error:&error];
if (error)
{        
    NSLog(@"Error with Healthkit Session: %@", error);
}
if (session == nil) 
{
    NSLog(@"*** Unable to create the workout session: %@ ***", error.localizedDescription);
    abort();
}

我正在使用Xcode 8,但就此而言,它也出现在Xcode 8 beta 3的模拟器中。当然使用Apple Series 2 Watch Simulator。

我收到以下错误。有什么东西我在这里做得非常错误,还是有其他方法来测试游泳训练课程?

*无法创建锻炼课程:此设备不支持游泳课程*

2 个答案:

答案 0 :(得分:1)

At the risk of stating the obvious, can you test it on an actual watch?

I've never tried doing exactly what you are doing here, but there are lots of other functions that aren't supported on the emulators - and looking at the error message that appears to be the case here.

Sorry I can't be more help

答案 1 :(得分:1)

无法在Apple Watch模拟器上测试游泳训练。您必须使用2系列硬件进行测试。