I am getting report of a crash occurring, while doing a NFC HCE CardSession.
The swift code is mostly the same as the example from the CardSession docs:
@objc func deviceSupportsNFC (_ call: CAPPluginCall) { call.keepAlive = true let supportsNFCCallbackId = call.callbackId! Task() { guard NFCReaderSession.readingAvailable, CardSession.isSupported, // <-- line 86 await CardSession.isEligible else { print(TAG + " HCE not allowed/available") var support = JSObject() support["supported"] = false; let callback = bridge?.savedCall(withID: supportsNFCCallbackId) call.resolve(); callback?.resolve(support); return; } print(TAG + " HCE allowed") var support = JSObject() support["supported"] = true; let callback = bridge?.savedCall(withID: supportsNFCCallbackId) call.resolve(); callback?.resolve(support); } }
Calling it from my plugin, to verify if (HCE) NFC is supported:
if(await deviceInfoService.isIos()) { if(iosSupportEnabled === false) { console.log("NfcHceService:iOS but disabled"); return; } this.requiresManualTrigger = true; DfsNfcHce.deviceSupportsNFC((supportObj) => { const support = supportObj?.supported ?? false; this.hceSupported = support; }); } else { this.hceSupported = true; }
The crash report i get via Crashlytics is below. It's specifying the error occurs at line 86 (marked it in my code above) The error seems to be in the CoreNFC (NFCHardwareManager areFeaturesSupported).
# Crashlytics - Stack trace # Application: com.wodanbrothers.dyflexis # Platform: apple # Version: 2025.04.101356 (1744977392) # Issue: c3a293fbfa73c64f59f92c4b4cdfeb83 # Session: 5c64465c452c41e3abb1ba9f970b54c0_DNE_0_v2 # Date: Wed May 07 2025 07:56:11 GMT+0200 (Central European Summer Time) Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0x11a2ec __exceptionPreprocess 1 libobjc.A.dylib 0x31a7c objc_exception_throw 2 CoreFoundation 0x18467c +[NSObject(NSObject) _copyDescription] 3 CoreFoundation 0x31b84 ___forwarding___ 4 CoreFoundation 0x314f0 _CF_forwarding_prep_0 5 CoreNFC 0x2ac40 -[NFCHardwareManager areFeaturesSupported:outError:] 6 CoreNFC 0x2b184 -[NFCHardwareManager areFeaturesSupported:expiry:completion:] 7 CoreNFC 0x2f9d8 block_destroy_helper.5 8 Dyflexis 0x5c08 closure #1 in DfsNfcHcePlugin.deviceSupportsNFC(_:) + 86 (DfsNfcHcePlugin.swift:86) 9 Dyflexis 0x7f8d <deduplicated_symbol> 10 Dyflexis 0x7725 specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) (<compiler-generated>) 11 Dyflexis 0x77fd <deduplicated_symbol> 12 libswift_Concurrency.dylib 0x65241 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError ... Crashed: com.google.firebase.crashlytics.ios.exception 0 FirebaseCrashlytics 0x1b658 FIRCLSProcessRecordAllThreads + 172 1 FirebaseCrashlytics 0x1ba64 FIRCLSProcessRecordAllThreads + 1208 2 FirebaseCrashlytics 0x13adc FIRCLSHandler + 48 3 FirebaseCrashlytics 0xe9d4 __FIRCLSExceptionRecord_block_invoke + 92 4 libdispatch.dylib 0x1b584 _dispatch_client_callout + 16 5 libdispatch.dylib 0x11728 _dispatch_lane_barrier_sync_invoke_and_complete + 56 6 FirebaseCrashlytics 0xe260 FIRCLSExceptionRecord + 204 7 FirebaseCrashlytics 0xe4f8 FIRCLSExceptionRecordNSException + 452 8 FirebaseCrashlytics 0xdeb8 FIRCLSTerminateHandler() + 396 9 libc++abi.dylib 0x158b4 std::__terminate(void (*)()) + 16 10 libc++abi.dylib 0x18e1c __cxa_get_exception_ptr + 86 11 libc++abi.dylib 0x18dc4 __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 90 12 libobjc.A.dylib 0x31be4 objc_exception_throw + 448 13 CoreFoundation 0x18467c +[NSObject(NSObject) _copyDescription] + 362 14 CoreFoundation 0x31b84 ___forwarding___ + 1492 15 CoreFoundation 0x314f0 _CF_forwarding_prep_0 + 96 16 CoreNFC 0x2ac40 -[NFCHardwareManager areFeaturesSupported:outError:] + 364 17 CoreNFC 0x2b184 -[NFCHardwareManager areFeaturesSupported:expiry:completion:] + 96 18 CoreNFC 0x2f9d8 block_destroy_helper.5 + 8028 19 Dyflexis 0x5c08 closure #1 in DfsNfcHcePlugin.deviceSupportsNFC(_:) + 86 (DfsNfcHcePlugin.swift:86) 20 libswift_Concurrency.dylib 0x5c134 swift::runJobInEstablishedExecutorContext(swift::Job*) + 292 21 libswift_Concurrency.dylib 0x5d5c8 swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) + 156 22 libdispatch.dylib 0x13db0 _dispatch_root_queue_drain + 364 23 libdispatch.dylib 0x1454c _dispatch_worker_thread2 + 156 24 libsystem_pthread.dylib 0x4624 _pthread_wqthread + 232 25 libsystem_pthread.dylib 0x19f8 start_wqthread + 8 ...