Gerd Castan Gerd Castan - 1 year ago 89
Swift Question

Missing Classes in XCode/Swift

In a Swift project I have the line

import HealthKit

Command Click opens a list of imports.

Command Click on any of these classes opens more.

Except: Command Click on

import HealthKit.HKWorkoutSession

opens an empty file.

This corresponds to compiler error messages HKWorkoutSession is unavailable and HKWorkoutSessionLocationType is unavailable in my code.

This started in XCode 7 beta 3 after using it a while. Moving to XCode 7 beta 4 didn't change anything. Cleaning the project doesn't change anything.

I suspect this has nothing to do with HealthKit but with some missing files.
So any idea how I can reinstall the HealthKit development files when installing a new XCode don't help? Or any other fix?


Missing Class

Answer Source

The HKWorkoutSession is available only in watchOS. Make sure you using in in the watchOS target.

Here is HKWorkoutSession documentation. Check the availability label when using it.
enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download