title: HealthKit Error "Protected health data is inaccessible"?
body: <p>I'm running into an occasional (not every time) error when attempting to load workout data from HealthKit on the iPhone:  <code>Error Domain=com.apple.healthkit Code=6 "Protected health data is inaccessible" {NSLocalizedDescription=Protected health data is inaccessible}</code></p>
  
  <p>The only other references to this error I've found is <a href="https://stackoverflow.com/questions/30361033/healthkit-data-inaccessible-in-background">when attempting to access HealthKit data when the phone is locked</a> 
  But I am attempting to load the data with the phone unlocked.  Any other idea what the issue could be? </p>
  
  <p>My HealthKit Permissions: </p>
  
  <pre><code>private func requestAccessToHealthKit() {
          let healthStore = HKHealthStore()
  
          let healthKitTypesToWrite: Set&lt;HKSampleType&gt; = [HKObjectType.workoutType(),
              HKSeriesType.workoutRoute(),
              HKObjectType.quantityType(forIdentifier: .activeEnergyBurned)!,
              HKObjectType.quantityType(forIdentifier: .heartRate)!,
              HKObjectType.quantityType(forIdentifier: .restingHeartRate)!,
              HKObjectType.quantityType(forIdentifier: .bodyMass)!,
              HKObjectType.quantityType(forIdentifier: .vo2Max)!,
              HKObjectType.quantityType(forIdentifier: .stepCount)!,
              HKObjectType.quantityType(forIdentifier: .distanceWalkingRunning)!]
  
          let healthKitTypesToRead: Set&lt;HKObjectType&gt; = [
              HKObjectType.workoutType(),
              HKSeriesType.workoutRoute(),
              HKObjectType.quantityType(forIdentifier: .activeEnergyBurned)!,
              HKObjectType.quantityType(forIdentifier: .heartRate)!,
              HKObjectType.quantityType(forIdentifier: .restingHeartRate)!,
              HKObjectType.characteristicType(forIdentifier: .dateOfBirth)!,
              HKObjectType.quantityType(forIdentifier: .bodyMass)!,
              HKObjectType.quantityType(forIdentifier: .vo2Max)!,
              HKObjectType.quantityType(forIdentifier: .stepCount)!,
              HKObjectType.quantityType(forIdentifier: .distanceWalkingRunning)!]
  
  
          healthStore.requestAuthorization(toShare: healthKitTypesToWrite, read: healthKitTypesToRead) { (success, error) in
              if !success {
                  print("failed HealthKit Authorization from iPhone \(String(describing: error?.localizedDescription))")
              }
  
              print("Successful HealthKit Authorization from iPhone")
          }
      }
  </code></pre>