Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
HKWorkoutSessionDelegate Not called

I am trying to start a workout session using HKWorkoutSession. It is not starting the session.

    let workoutConfiguration = HKWorkoutConfiguration()
    workoutConfiguration.activityType = .running
    workoutConfiguration.locationType = .outdoor

    do {
        session = try HKWorkoutSession(healthStore: healthStore!, configuration: workoutConfiguration)
        session?.delegate = self
        session?.startActivity(with: Date())
        print((session?.state)!.rawValue)
    } catch let error {
        print(error)
    }

The HKWorkoutSessionDelegate method

func workoutSession(_ workoutSession: HKWorkoutSession, didChangeTo toState: HKWorkoutSessionState, from fromState: HKWorkoutSessionState, date: Date)

Never gets called.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I've seen this a few times (not enough to recreate or anything).

I think restarting Xcode and the Simulator helps.

over 4 years ago · Santiago Trujillo Report

0

Are you trying this on simulator? If you are, I'd try on device. If on device, this could be because you haven't accepted HealthKit permissions? Check in Privacy->Health to see if your app has permissions for HealthKit.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!