is not key value coding-compliant for the key
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MBNavigationSettings 0x125a3d170> valueForUndefinedKey:]: this class is not key value coding-compliant for the key $_lazy_storage$_properties.'
MBNavigationViewController *controller = [[MBNavigationViewController alloc] initWithRoute:self.directionsRoute styles:nil navigationService:service voiceController: nil];
Something went wrong here
I'm seeing the same issue after moving to Xcode 11.1 and Swift 5.1 from Xcode 10.2 and Swift 5.0.
Here's the stack trace:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MBNavigationSettings 0x7f89ace603b0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key $_lazy_storage$_properties.' *** First throw call stack: ( 0 CoreFoundation 0x0000000110ee78db __exceptionPreprocess + 331 1 libobjc.A.dylib 0x000000010fff1ac5 objc_exception_throw + 48 2 CoreFoundation 0x0000000110ee7449 -[NSException raise] + 9 3 Foundation 0x000000010bf4b29e -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 226 4 Foundation 0x000000010bf4a0e3 -[NSObject(NSKeyValueCoding) valueForKey:] + 281 5 MapboxCoreNavigation 0x000000010d7cfb1c $s20MapboxCoreNavigation0C8SettingsCACycfc + 892 6 MapboxCoreNavigation 0x000000010d7cfcff $s20MapboxCoreNavigation0C8SettingsCACycfcTo + 15 7 MapboxCoreNavigation 0x000000010d7cf58a globalinit_33_B2395CD5FC7CEA296E0D5EA5544E4D86_func60 + 58 8 libdispatch.dylib 0x0000000113907db5 _dispatch_client_callout + 8 9 libdispatch.dylib 0x000000011390983c _dispatch_once_callout + 66 10 libswiftCore.dylib 0x0000000113094579 swift_once + 25 11 MapboxCoreNavigation 0x000000010d7cf1c1 $s20MapboxCoreNavigation0C8SettingsC6sharedACvau + 33 12 MapboxNavigation 0x000000010f0379d1 $s16MapboxNavigation20RouteVoiceControllerC20observeNotifications2byy0a4CoreB00B7Service_p_tF + 529 13 MapboxNavigation 0x000000010f03960a $s16MapboxNavigation20RouteVoiceControllerC17navigationServiceAC0a4CoreB00bG0_p_tcfcTf4gn_n + 1706 14 MapboxNavigation 0x000000010f0e7f69 $s16MapboxNavigation0A15VoiceControllerC17navigationService12speechClient9dataCache15audioPlayerTypeAC0a4CoreB00bF0_p_0A6Speech0O11SynthesizerCAA011BimodalDataJ0_pSo07AVAudioL0CmSgtcfc + 601 15 MapboxNavigation 0x000000010f03f056 $s16MapboxNavigation0B14ViewControllerC3for7optionsAC0A10Directions5RouteC_AA0B7OptionsCSgtcfc + 1366 16 TCMobile 0x000000010a97c429 $s8TCMobile24NavigationViewControllerC11MapboxNavVCC3for7optionsAE0E10Directions5RouteC_0eB00B7OptionsCSgtcfc + 313 17 TCMobile 0x000000010a967d2a $s8TCMobile24NavigationViewControllerC11MapboxNavVCC3for7optionsAE0E10Directions5RouteC_0eB00B7OptionsCSgtcfC + 58 18 TCMobile 0x000000010a965cae $s8TCMobile24NavigationViewControllerC013presentMapboxbcD033_2E1D1E2D73CBA4C513B12BB1F620938DLLyyF + 1278
It's failing on:
line 121: muteToken = NavigationSettings.shared.observe(.voiceMuted) { [weak self] (settings, change) in
in RouteVoiceController.swift (when generating a new RouteVoiceController)
Looks like the lazy var properties on NavigationSettings is triggering an error during the observe call on the shared NavigationSettings.
Looks like the label response from Mirror(reflecting: self).children changed between 5.0 and 5.1
5.0 output:
▿ 4 elements
▿ 0 : 2 elements
▿ label : Optional
5.1 output:
▿ 4 elements
▿ 0 : 2 elements
▿ label : Optional
Since properties is trying to exclude itself from the reflection, this is now failing because the matching string changed from "properties.storage" to "$_lazy_storage$_properties"
Should possibly do a more generic check for string containing "properties" instead of a rigid pattern matching.
Exact same issue in my project too since recent Xcode and iOS upgrades.
Just write this code in the attach pod file and it will work
super.init()
for property in properties {
guard let key = property.label else { continue }
-
let val = UserDefaults.standard.object(forKey: key.prefixed) ?? value(forKey: key) -
setValue(val, forKey: key) -
addObserver(self, forKeyPath: key, options: .new, context: nil)
-
if(key != "$__lazy_storage_$_properties") -
{ -
let val = UserDefaults.standard.object(forKey: key.prefixed) ?? value(forKey: key) -
setValue(val, forKey: key) -
addObserver(self, forKeyPath: key, options: .new, context: nil) -
}} }
Tried this suggested solution and still the same issue.
Ok - update your Pods, fixed the issue! :)
Thank you. I update my Xcode,and the problem is solved
I had this issue with Navigation SDK v0.38.0 and Xcode 11.1 also Xcode 11.2.1. I removed the lazy keyword from "var properties: [Mirror.Child]" in NavigationSettings.swift and the problem was solved.
I’m surprised you’re seeing this issue in v0.38.0. #2156 specifically checked for $__lazy_storage_$_properties and went into v0.35.0.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Stale.