HKWorkoutSession in Beta 4 seems to require a different setup?

So I just upgraded to beta 4, and not my code for starting an HKWorkoutSession no-longer compiles.


I get the error "Extra argument in call" on this line:

healthStore.startWorkoutSession(workoutSession) { success, error in
}


So I replaced it with this which does not error just by letting the suggestions as I type guide me:

healthStore.startWorkoutSession(workoutSession)


Now that that error is gone, I am getting 7 errors on my implementation of HKWorkoutSessionDelegate, the primary one saying that "HKWorkoutSessionDelegate is unavailable". Seeing this, I feel like I need some updated documentation to figure out how to implement this in the new beta. All of the documentation for these classes seems to have been last updated in June, so that's no help.


How does one typically continue developing in these situations?

Answered by gtzpower in 30669022

I figured it out. The files generating errors were being included in my iOS target as well. The new beta must have restricted those classes to the WatchKit extensions. After removing the iOS app from the target membership on the problematic files, it seems to work now.


Time to properly refactor some iOS code now.

Does the class conforming to the HKWorkoutSessionDelegate protocol subclass from NSObject?

Yes is does. It inherits NSObject and HKWorkoutSessionDelegate. The code was all working fine just yesterday, and after upgrading to xCode beta 4, I get errors on this code.

Accepted Answer

I figured it out. The files generating errors were being included in my iOS target as well. The new beta must have restricted those classes to the WatchKit extensions. After removing the iOS app from the target membership on the problematic files, it seems to work now.


Time to properly refactor some iOS code now.

HKWorkoutSession in Beta 4 seems to require a different setup?
 
 
Q