Skip to content

[health] TOTAL_CALORIES_BURNED in dataTypeKeysIOS but missing from iOS dataTypesDict causes SIGABRT crash #486

@mcaldas

Description

@mcaldas

Bug Report

Package

health: 13.3.1

Platform

iOS (simulator, iOS 26.4)

Description

TOTAL_CALORIES_BURNED is listed in dataTypeKeysIOS (in lib/src/heath_data_types.dart) but is not registered in the native iOS dataTypesDict dictionary (in ios/Classes/SwiftHealthPlugin.swift).

When requestAuthorization is called with this type on iOS, the native code looks up the type in dataTypesDict, gets nil, and passes nil into HKHealthStore._validateAuthorizationRequestWithShareTypes:readTypes:, which throws an NSException (SIGABRT) — killing the app process immediately.

The crash is not catchable in Dart because it is a native-level abort, not a thrown Dart exception.

Steps to Reproduce

  1. Add health: ^13.3.1 to your Flutter project
  2. Call health.requestAuthorization([HealthDataType.TOTAL_CALORIES_BURNED]) on an iOS simulator (or device)
  3. App crashes immediately with SIGABRT

Crash Log

"exception" : {"codes":"0x0000000000000000, 0x0000000000000000","rawCodes":[0,0],"type":"EXC_CRASH","signal":"SIGABRT"},
"termination" : {"flags":0,"code":6,"namespace":"SIGNAL","indicator":"Abort trap: 6"},
"lastExceptionBacktrace" : [
  __exceptionPreprocess,
  objc_exception_throw,
  -[HKHealthStoreImplementation _validateAuthorizationRequestWithShareTypes:readTypes:],
  -[HKHealthStoreImplementation requestAuthorizationToShareTypes:readTypes:shouldPrompt:completion:],
  HealthDataOperations.requestAuthorization(call:result:)
]

Expected Behavior

Either:

  • Option A: Register TOTAL_CALORIES_BURNED in dataTypesDict on iOS (e.g., mapping to a combined active + basal energy type), or
  • Option B: Remove TOTAL_CALORIES_BURNED from dataTypeKeysIOS so it is not advertised as a supported iOS type.

Relevant Files

  • lib/src/heath_data_types.dartTOTAL_CALORIES_BURNED listed in dataTypeKeysIOS
  • ios/Classes/SwiftHealthPlugin.swiftdataTypesDict does not contain a mapping for TOTAL_CALORIES_BURNED

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions