Post

Replies

Boosts

Views

Activity

Reply to HKObserverQuery updateHandler is getting fired twice in a row
I also tried with:     func setUpBackgroundDelivery() async {         var queryDescriptors = [HKQueryDescriptor]()         for type in types {             queryDescriptors.append(HKQueryDescriptor(sampleType: type, predicate: nil))         }         let observerQuery = HKObserverQuery(queryDescriptors: queryDescriptors) { query, sampleTypesWithNewData, completionHandler, error in             if let error = error {                 self.logger.error("HKObserverQuery error: \(error.localizedDescription)")                 completionHandler()                 return             }             for type in sampleTypesWithNewData! {                 self.logger.debug("New \(type.debugDescription) data")                 self.anchoredQueryFor(sampleTypesWithNewData!)             }             completionHandler()         }         HKStore.execute(observerQuery)         for type in types {             do {                 try await HKStore.enableBackgroundDelivery(for: type, frequency: .hourly)             } catch {                 self.logger.error("setUpBackgroundDeliveryFor \(type) - error: \(error.localizedDescription)")             }         }     } And the update handler gets called twice: 2022-06-10 10:54:06.464318+0200 Cori[81627:9010600] [HealthKit] New HKQuantityTypeIdentifierBloodGlucose data 2022-06-10 10:54:06.467039+0200 Cori[81627:9010600] [HealthKit] New HKQuantityTypeIdentifierBloodGlucose data 2022-06-10 10:54:06.472524+0200 Cori[81627:9010601] [HealthKit] New data: [222 mg/dL 6AA78B15-4EB5-4F80-823E-DFBC43AB3C5A "Salud" (15.5), "iPhone14,2" (15.5)metadata: { 2022-06-10 10:54:06.472742+0200 Cori[81627:9010601] [HealthKit] 1 new HKQuantityTypeIdentifierBloodGlucose samples 2022-06-10 10:54:06.472889+0200 Cori[81627:9010591] [persistence] HealthKit: Start import to Core Data 2022-06-10 10:54:06.473032+0200 Cori[81627:9010591] [persistence] HealthKit: 1 samples of type HKQuantityTypeIdentifierBloodGlucose not from this app! 2022-06-10 10:54:06.473103+0200 Cori[81627:9010591] [persistence] HealthKit: Start batch insert request. 2022-06-10 10:54:06.473356+0200 Cori[81627:9010601] [HealthKit] New data: [222 mg/dL 6AA78B15-4EB5-4F80-823E-DFBC43AB3C5A "Salud" (15.5), "iPhone14,2" (15.5)metadata: { 2022-06-10 10:54:06.475530+0200 Cori[81627:9010591] [persistence] HealthKit: Successfully imported data. 2022-06-10 10:54:06.493688+0200 Cori[81627:9010601] [HealthKit] 1 new HKQuantityTypeIdentifierBloodGlucose samples 2022-06-10 10:54:06.493899+0200 Cori[81627:9010591] [persistence] HealthKit: Start import to Core Data 2022-06-10 10:54:06.494013+0200 Cori[81627:9010591] [persistence] HealthKit: 1 samples of type HKQuantityTypeIdentifierBloodGlucose not from this app! 2022-06-10 10:54:06.494057+0200 Cori[81627:9010591] [persistence] HealthKit: Start batch insert request. 2022-06-10 10:54:06.495381+0200 Cori[81627:9010601] [persistence] HealthKit: Successfully imported data.
Jun ’22
Reply to HKObserverQuery updateHandler is getting fired twice in a row
Hi @eschos24! I still have the problem but found a little workaround by building a semaphore using Swift Actor's. So the import function only fires once every 10 seconds. actor Semaphore {     static let shared = Semaphore()          var isImporting = false     func run(sleeping: UInt32 = 5, function: @escaping () async -> Void) async {         if !isImporting {             isImporting = true             await function()             sleep(sleeping)             isImporting = false         }     } } This is it in action private func setUpBackgroundDelivery() async {         var queryDescriptors = [HKQueryDescriptor]()         for type in types {             queryDescriptors.append(HKQueryDescriptor(sampleType: type, predicate: nil))         }         let observerQuery = HKObserverQuery(queryDescriptors: queryDescriptors) { query, sampleTypesWithNewData, completionHandler, error in             if let error = error {                 completionHandler()                 return             }             Task {                 await self.semaphore.run(sleeping: 10) {                     await self.checkForNewWorkouts()                 }                 completionHandler()             }         }         HKStore.execute(observerQuery)         do {             try await HKStore.enableBackgroundDelivery(for: workout, frequency: .hourly)         } catch {         }     }
Sep ’22
Reply to App can't debug on iOS 26 device, but can on iOS 18
I'm having the same problem with iOS 26 phone simulators on Xcode Beta 3 but not on iOS 18.5 simulators. Failed to iterate on macho slices for input file: /Users/asiergmorato/Library/Developer/CoreSimulator/Devices/D8BDCB2C-690F-4D08-A87D-AC05851CD89F/data/Library/Caches/com.apple.mobile.installd.staging/temp.AnaSyj/extracted/FitWoody.app/Watch/FitWoody-Watch.app/Frameworks/powersync-sqlite-core.framework/powersync-sqlite-core App installation failed: No se puede instalar FitWoody Domain: IXUserPresentableErrorDomain Code: 1 Failure Reason: Inténtalo de nuevo más tarde. Recovery Suggestion: Failed to iterate on macho slices for input file: /Users/asiergmorato/Library/Developer/CoreSimulator/Devices/D8BDCB2C-690F-4D08-A87D-AC05851CD89F/data/Library/Caches/com.apple.mobile.installd.staging/temp.YEGeGW/extracted/FitWoody.app/Watch/FitWoody-Watch.app/Frameworks/powersync-sqlite-core.framework/powersync-sqlite-core User Info: { DVTErrorCreationDateKey = "2025-07-13 15:39:48 +0000"; IDERunOperationFailingWorker = IDELaunchiPhoneSimulatorLauncher; SimCallingSelector = "installApplication:withOptions:error:"; } -- No se puede instalar FitWoody Domain: IXUserPresentableErrorDomain Code: 1 Failure Reason: Inténtalo de nuevo más tarde. Recovery Suggestion: Failed to iterate on macho slices for input file: /Users/asiergmorato/Library/Developer/CoreSimulator/Devices/D8BDCB2C-690F-4D08-A87D-AC05851CD89F/data/Library/Caches/com.apple.mobile.installd.staging/temp.YEGeGW/extracted/FitWoody.app/Watch/FitWoody-Watch.app/Frameworks/powersync-sqlite-core.framework/powersync-sqlite-core -- Failed to iterate on macho slices for input file: /Users/asiergmorato/Library/Developer/CoreSimulator/Devices/D8BDCB2C-690F-4D08-A87D-AC05851CD89F/data/Library/Caches/com.apple.mobile.installd.staging/temp.YEGeGW/extracted/FitWoody.app/Watch/FitWoody-Watch.app/Frameworks/powersync-sqlite-core.framework/powersync-sqlite-core Domain: MIInstallerErrorDomain Code: 73 User Info: { FunctionName = MIMachOFileIterateImageVersions; SourceFileLine = 132; } -- parse_macho_iterate_slices failed for /Users/asiergmorato/Library/Developer/CoreSimulator/Devices/D8BDCB2C-690F-4D08-A87D-AC05851CD89F/data/Library/Caches/com.apple.mobile.installd.staging/temp.YEGeGW/extracted/FitWoody.app/Watch/FitWoody-Watch.app/Frameworks/powersync-sqlite-core.framework/powersync-sqlite-core Domain: NSPOSIXErrorDomain Code: 0 Failure Reason: Undefined error: 0 User Info: { FunctionName = MIMachOFileIterateImageVersions; SourceFileLine = 132; } -- Event Metadata: com.apple.dt.IDERunOperationWorkerFinished : { "device_identifier" = "D8BDCB2C-690F-4D08-A87D-AC05851CD89F"; "device_model" = "iPhone17,1"; "device_osBuild" = "26.0 (23A5287g)"; "device_osBuild_monotonic" = 2300528706; "device_os_variant" = 1; "device_platform" = "com.apple.platform.iphonesimulator"; "device_platform_family" = 2; "device_reality" = 2; "device_thinningType" = "iPhone17,1"; "device_transport" = 4; "dvt_coredevice_version" = "477.25"; "dvt_coredevice_version_monotonic" = 477025000000000; "dvt_coresimulator_version" = 1043; "dvt_coresimulator_version_monotonic" = 1043000000000000; "dvt_mobiledevice_version" = "1818.0.1"; "dvt_mobiledevice_version_monotonic" = 1818000001000000; "launchSession_schemeCommand" = Run; "launchSession_schemeCommand_enum" = 1; "launchSession_targetArch" = arm64; "launchSession_targetArch_enum" = 6; "operation_duration_ms" = 23567; "operation_errorCode" = 1; "operation_errorDomain" = IXUserPresentableErrorDomain; "operation_errorWorker" = IDELaunchiPhoneSimulatorLauncher; "operation_error_reportable" = 1; "operation_name" = IDERunOperationWorkerGroup; "param_consoleMode" = 1; "param_debugger_attachToExtensions" = 0; "param_debugger_attachToXPC" = 1; "param_debugger_type" = 3; "param_destination_isProxy" = 0; "param_destination_platform" = "com.apple.platform.iphonesimulator"; "param_diag_MainThreadChecker_stopOnIssue" = 0; "param_diag_MallocStackLogging_enableDuringAttach" = 0; "param_diag_MallocStackLogging_enableForXPC" = 1; "param_diag_allowLocationSimulation" = 1; "param_diag_checker_mtc_enable" = 1; "param_diag_checker_tpc_enable" = 1; "param_diag_gpu_frameCapture_enable" = 0; "param_diag_gpu_shaderValidation_enable" = 0; "param_diag_gpu_validation_enable" = 0; "param_diag_guardMalloc_enable" = 0; "param_diag_memoryGraphOnResourceException" = 0; "param_diag_queueDebugging_enable" = 1; "param_diag_runtimeProfile_generate" = 0; "param_diag_sanitizer_asan_enable" = 0; "param_diag_sanitizer_tsan_enable" = 0; "param_diag_sanitizer_tsan_stopOnIssue" = 0; "param_diag_sanitizer_ubsan_enable" = 0; "param_diag_sanitizer_ubsan_stopOnIssue" = 0; "param_diag_showNonLocalizedStrings" = 0; "param_diag_viewDebugging_enabled" = 1; "param_diag_viewDebugging_insertDylibOnLaunch" = 1; "param_install_style" = 2; "param_launcher_UID" = 2; "param_launcher_allowDeviceSensorReplayData" = 0; "param_launcher_kind" = 0; "param_launcher_style" = 0; "param_launcher_substyle" = 0; "param_lldbVersion_component_idx_1" = 0; "param_lldbVersion_monotonic" = 170300260101; "param_runnable_appExtensionHostRunMode" = 0; "param_runnable_productType" = "com.apple.product-type.application"; "param_testing_launchedForTesting" = 0; "param_testing_suppressSimulatorApp" = 0; "param_testing_usingCLI" = 0; "sdk_canonicalName" = "iphonesimulator26.0"; "sdk_osVersion" = "26.0"; "sdk_platformID" = 7; "sdk_variant" = iphonesimulator; "sdk_version_monotonic" = 2300528704; } -- System Information macOS Version 15.5 (Build 24F74) Xcode 26.0 (24179.3) (Build 17A5276g) Timestamp: 2025-07-13T17:39:48+02:00
Jul ’25