krokyze / FitKit

Flutter plugin for reading health and fitness data. Wraps HealthKit on iOS and GoogleFit on Android.
BSD 2-Clause "Simplified" License
98 stars 73 forks source link

Crash on iOS #38

Closed RafaRuiz closed 4 years ago

RafaRuiz commented 4 years ago

Hello. I'm using:

Future<void> fit() async {
  List<DataType> dataTypes = [DataType.STEP_COUNT, DataType.ENERGY];
  if (await FitKit.requestPermissions(dataTypes)) {
    for (DataType type in dataTypes) {
      final results = await FitKit.read(
        type,
        dateFrom: Jiffy().subtract(days: 1),
        dateTo: DateTime.now(),
      );
    }
  }
}

and it crashes for iOS right in await FitKit.requestPermissions(dataTypes)

The log I have from the simulator is:

2020-01-25 19:03:03.857700+0100 Runner[71026:823677] -[NSCFBoolean hk_isValidPurposeString]: unrecognized selector sent to instance 0x7fff8061ea08 2020-01-25 19:03:03.877971+0100 Runner[71026:823677] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean hk_isValidPurposeString]: unrecognized selector sent to instance 0x7fff8061ea08' First throw call stack: ( 0 CoreFoundation 0x00007fff23c7127e exceptionPreprocess + 350 1 libobjc.A.dylib 0x00007fff513fbb20 objc_exception_throw + 48 2 CoreFoundation 0x00007fff23c91fd4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 CoreFoundation 0x00007fff23c75c4c forwarding + 1436 4 CoreFoundation 0x00007fff23c77f78 _CF_forwarding_prep_0 + 120 5 HealthKit 0x00007fff25aa522e -[HKHealthStore _validateHealthDataPurposeStringsForSharingTypes:readingTypes:isResearchStudy:] + 885 6 HealthKit 0x00007fff25aa4bd7 -[HKHealthStore _validatePurposeStringsForSharingTypes:readingTypes:] + 384 7 HealthKit 0x00007fff25aa43c2 -[HKHealthStore requestAuthorizationToShareTypes:readTypes:shouldPrompt:completion:] + 354 8 HealthKit 0x00007fff25aa412e -[HKHealthStore requestAuthorizationToShareTypes:readTypes:completion:] + 77 9 fit_kit 0x0000000110ca82b4 $s7fit_kit17SwiftFitKitPluginC20requestAuthorization33_B5B63DA1CEDF30F36A7BBB05B461F1D3LL11sampleTypes10completionySaySo12HKSampleTypeCG_ySb_So12FlutterErrorCSgtctF + 756 10 fit_kit 0x0000000110ca79e2 $s7fit_kit17SwiftFitKitPluginC18requestPermissions33_B5B63DA1CEDF30F36A7BBB05B461F1D3LL0G06resultyAA0H7RequestC_yypSgctF + 146 11 fit_kit 0x0000000110ca5e12 $s7fit_kit17SwiftFitKitPluginC6handle_6resultySo17FlutterMethodCallC_yypSgctF + 1154 12 fit_kit 0x0000000110ca694b $s7fit_kit17SwiftFitKitPluginC6handle_6resultySo17FlutterMethodCallC_yypSgctFTo + 139 13 Flutter 0x000000010ec2533b 45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 104 14 Flutter 0x000000010ebb6130 _ZNK7flutter21PlatformMessageRouter21HandlePlatformMessageEN3fml6RefPtrINS_15PlatformMessageEEE + 166 15 Flutter 0x000000010ebb9bde _ZN7flutter15PlatformViewIOS21HandlePlatformMessageEN3fml6RefPtrINS_15PlatformMessageEEE + 38 16 Flutter 0x000000010ec1e64d _ZNSt3110function6__funcIZN7flutter5Shell29OnEngineHandlePlatformMessageEN3fml6RefPtrINS2_15PlatformMessageEEEE4$_32NS_9allocatorIS8_EEFvvEEclEv + 57 17 Flutter 0x000000010ebc9cd7 _ZN3fml15MessageLoopImpl10FlushTasksENS_9FlushTypeE + 117 18 Flutter 0x000000010ebcea1c _ZN3fml17MessageLoopDarwin11OnTimerFireEP16CFRunLoopTimerPS0_ + 26 19 CoreFoundation 0x00007fff23bd4b94 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 20 20 CoreFoundation 0x00007fff23bd4882 CFRunLoopDoTimer + 1026 21 CoreFoundation 0x00007fff23bd3eda CFRunLoopDoTimers + 266 22 CoreFoundation 0x00007fff23bcec4e __CFRunLoopRun + 2238 23 CoreFoundation 0x00007fff23bce066 CFRunLoopRunSpecific + 438 24 GraphicsServices 0x00007fff384c0bb0 GSEventRunModal + 65 25 UIKitCore 0x00007fff48092d4d UIApplicationMain + 1621 26 Runner 0x000000010e8730c8 main + 72 27 libdyld.dylib 0x00007fff5227ec25 start + 1 28 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException

and this is the crash from a device:

2020-01-25 19:09:48.345991+0100 Runner[392:12243] -[__NSCFBoolean hk_isValidPurposeString]: unrecognized selector sent to instance 0x1d1d655d0 2020-01-25 19:09:48.346631+0100 Runner[392:12243] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean hk_isValidPurposeString]: unrecognized selector sent to instance 0x1d1d655d0' First throw call stack: (0x19568b278 0x1953b40a4 0x19558ef94 0x19568f5d8 0x19569110c 0x1a85fe83c 0x1a85fe2b8 0x1a85fdadc 0x1a85fd828 0x100a76540 0x100a75c30 0x100a74108 0x100a74ae4 0x100e677c8 0x100dfdc48 0x100e58324 0x100e0e71c 0x100e10a28 0x1956096cc 0x195609408 0x195608ad8 0x195603c14 0x19560316c 0x19f43b328 0x19966dd0c 0x1009c8cd8 0x19548e424) libc++abi.dylib: terminating with uncaught exception of type NSException

I'm using an automatic signed certificate and HealthKit is "enabled":

image