Unexpected non-void return value in void function

  //MARK : HealthStore   func getData() -> Double {     //Get Authorization     let stepType = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.stepCount)!     let heartRate = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.heartRate)!     let spo2 = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.respiratoryRate)!     healthStore.requestAuthorization(toShare: [], read: [stepType,heartRate,spo2]) { (chk, error) in       if (chk){         print("Permission Granted")                   var dumm = 0.0         //currentHeartRate(completion: nil)         self.getSteps(currentDate: Date()) { result in           globalString.todayStepsCount = result           dumm = result           print(result)         }         return dumm       }                    }         } //getData             func getSteps(currentDate: Date, completion: @escaping (Double) -> Void) {     guard let sampleType = HKCategoryType.quantityType(forIdentifier: .stepCount) else {       print("Get Steps not executed as is null")       return     }     let now = currentDate //Date()     let startDate = Calendar.current.startOfDay(for: now)     let predicate = HKQuery.predicateForSamples(withStart: startDate, end: now, options: .strictEndDate)     let query = HKStatisticsQuery(quantityType: sampleType, quantitySamplePredicate: predicate, options: .cumulativeSum)     { _, result, _ in         guard let result = result, let sum = result.sumQuantity() else {           completion(0.0)           return         }         completion(sum.doubleValue(for: HKUnit.count()))       }

    healthStore.execute(query)   }

In getData(), you "return dumm" within a closure which executes asynchronously.
That is, it can execute after getData() has returned.

So getData cannot return it's Double value there.
The closure itself does not return a value (hence the error message).
And since you only retrieve "dumm" within the closure, you cannot use getData's return value to return dumm.

You should probably remove the return value from getData, and handle the closure's result somehow (e.g. by passing a completion closure to getData, which can then process "dumm").

By the way, it would be easier to help you if you could use (instead of your mass of code, and a screenshot) a Code Block for your code, and use "Paste and Match Style".

Like this:

//MARK : HealthStore
func getData() -> Double {
    //Get Authorization
    let stepType = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.stepCount)!
    let heartRate = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.heartRate)!
    let spo2 = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.respiratoryRate)!
    healthStore.requestAuthorization(toShare: [], read: [stepType,heartRate,spo2]) { (chk, error) in
        if (chk){
            print("Permission Granted")
            var dumm = 0.0
            //currentHeartRate(completion: nil)
            self.getSteps(currentDate: Date()) { result in
                globalString.todayStepsCount = result
                dumm = result
                print(result)
            }
            return dumm
        }
    }
    
}
//getData
func getSteps(currentDate: Date, completion: @escaping (Double) -> Void) {
    guard let sampleType = HKCategoryType.quantityType(forIdentifier: .stepCount) else {
        print("Get Steps not executed as is null")
        return
    }
    let now = currentDate
    //Date()
    let startDate = Calendar.current.startOfDay(for: now)
    let predicate = HKQuery.predicateForSamples(withStart: startDate, end: now, options: .strictEndDate)
    let query = HKStatisticsQuery(quantityType: sampleType, quantitySamplePredicate: predicate, options: .cumulativeSum)     { _, result, _ in
        guard let result = result,
                let sum = result.sumQuantity() else {
            completion(0.0)
            return
        }
        completion(sum.doubleValue(for: HKUnit.count()))
    }
    healthStore.execute(query)
}
Unexpected non-void return value in void function
 
 
Q