Library version: 11.1.2
react-native-nitro-modules version: (check your lockfile)
React Native version: 0.74.1
Expo SDK: N/A (bare React Native)
Device: iPhone 16 Pro (iPhone17,1)
OS: iPhone OS 26.4 (23E246) — beta
What happens:
App crashes on launch in TestFlight. Crash happens ~2-3 seconds after launch on a GCD background workqueue thread (com.apple.root.default-qos) while HealthKit is establishing its XPC connection to com.apple.healthd.
Stack trace (all 7 crash reports share the identical stack):
Foundation -[NSSortDescriptor encodeWithCoder:] ← throws NSException
Foundation -[NSXPCEncoder _encodeObject:]
Foundation -[NSXPCEncoder _encodeArrayOfObjects:forKey:]
Foundation -[NSArray encodeWithCoder:]
HealthKit -[_HKSampleQueryConfiguration encodeWithCoder:]
Foundation NSXPCConnection _sendInvocation...
HealthKit HKQueryServerProxyProvider fetchProxyServiceEndpoint...
HealthKit HKHealthStoreImplementation _serverProxyWithHandler...
Root cause:
On iOS 26.4 beta, NSSortDescriptor throws an NSException when NSXPCEncoder attempts to serialize it. HKSampleQuery passes sortDescriptors over XPC to healthd, which triggers the crash. This is a regression in iOS 26.x's NSXPC serialization layer — NSSortDescriptor encoded fine on all prior iOS versions.
The crash originates from getSortDescriptors() in Helpers.swift:
// This crashes on iOS 26.x beta:
func getSortDescriptors(ascending: Bool?) -> [NSSortDescriptor] {
return [NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: ascending ?? false)]
}
Called at QuantityTypeModule.swift:19 and CategoryTypeModule.swift:49.
Fix:
Return nil instead of an NSSortDescriptor array. The HKSampleQuery API accepts an optional sort descriptor array — passing nil means unsorted results from the native layer, which is fine since sorting can be handled in JavaScript.
func getSortDescriptors(ascending: Bool?) -> [NSSortDescriptor]? {
// Returning nil: NSSortDescriptor crashes NSXPCEncoder on iOS 26.x beta
return nil
} -> Still testing not quite sure if it's going to work as expected!
Workaround (patch-package):
We are currently using patch-package to apply this fix locally until it is addressed upstream.
Additional notes:
- Affects all HKSampleQuery calls: queryQuantitySamples, queryCategorySamples, queryWorkoutSamples
- Reproducible 100% of the time on iOS 26.4 (23E246) beta, iPhone17,1
- Does not affect any other iOS version
- Minimum deployment target: iOS 16.2
Library version: 11.1.2
react-native-nitro-modules version: (check your lockfile)
React Native version: 0.74.1
Expo SDK: N/A (bare React Native)
Device: iPhone 16 Pro (iPhone17,1)
OS: iPhone OS 26.4 (23E246) — beta
What happens:
App crashes on launch in TestFlight. Crash happens ~2-3 seconds after launch on a GCD background workqueue thread (com.apple.root.default-qos) while HealthKit is establishing its XPC connection to com.apple.healthd.
Stack trace (all 7 crash reports share the identical stack):
Foundation -[NSSortDescriptor encodeWithCoder:] ← throws NSException
Foundation -[NSXPCEncoder _encodeObject:]
Foundation -[NSXPCEncoder _encodeArrayOfObjects:forKey:]
Foundation -[NSArray encodeWithCoder:]
HealthKit -[_HKSampleQueryConfiguration encodeWithCoder:]
Foundation NSXPCConnection _sendInvocation...
HealthKit HKQueryServerProxyProvider fetchProxyServiceEndpoint...
HealthKit HKHealthStoreImplementation _serverProxyWithHandler...
Root cause:
On iOS 26.4 beta, NSSortDescriptor throws an NSException when NSXPCEncoder attempts to serialize it. HKSampleQuery passes sortDescriptors over XPC to healthd, which triggers the crash. This is a regression in iOS 26.x's NSXPC serialization layer — NSSortDescriptor encoded fine on all prior iOS versions.
The crash originates from getSortDescriptors() in Helpers.swift:
// This crashes on iOS 26.x beta:
func getSortDescriptors(ascending: Bool?) -> [NSSortDescriptor] {
return [NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: ascending ?? false)]
}
Called at QuantityTypeModule.swift:19 and CategoryTypeModule.swift:49.
Fix:
Return nil instead of an NSSortDescriptor array. The HKSampleQuery API accepts an optional sort descriptor array — passing nil means unsorted results from the native layer, which is fine since sorting can be handled in JavaScript.
func getSortDescriptors(ascending: Bool?) -> [NSSortDescriptor]? {
// Returning nil: NSSortDescriptor crashes NSXPCEncoder on iOS 26.x beta
return nil
} -> Still testing not quite sure if it's going to work as expected!
Workaround (patch-package):
We are currently using patch-package to apply this fix locally until it is addressed upstream.
Additional notes: