After installing Xcode 11, when testing on iOS 12 mobile device, the following error keeps appearing. It always crashes the application.
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UISegmentedControl 0x107c7ec90> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key selectedSegmentTintColor.'
On iOS 13, it does not crash.
This error was caused from setting Selected Tint
color from xib file. When it is set to a predefined color (in Colors.xcassets
), it would cause the above error on runtime and crash the app.
To handle tint color that would work, it has to be done programmatically.
if #available(iOS 13.0, *) {
unitSegment.selectedSegmentTintColor = UIColor(named: "Primary")!
} else {
unitSegment.tintColor = UIColor(named: "Primary")!
}
As of now, the crashing error appears on both Xcode 11.0 and Xcode 11.1.
Apple should have handled this by default on Xcode and Swift 5.1, or at least prompted an error upon choosing a predefined color on xib file especially when my target is set to 12.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With