I have a class that returns a UIColor from my custom palette. I call this programmatically but when I tested it on iOS 11 it always returns a nil
result... I tried this on multiple devices and OS versions 11.0, 11.0.1, 11.2 and all of them returns nil
. But as soon as I run them on >iOS 12 it always returns a correct color.
var color: UIColor? {
switch self {
case .darkIndigo: return UIColor(named: "darkIndigo")
case .lightNavy: return UIColor(named: "lightNavy")
case .cobalt: return UIColor(named: "cobalt")
}
}
I have recently changed my bundle ID for the app... and this makes me think that it has something to do with the similar problem that UIImage has when multiple bundles are used. Especially when I get the error message
WARNING: Unable to resolve the color named "darkIndigo" from any of the following bundles:
But how is this supposed to be resolved? Should I just manually remove the whole asset catalogue and add them back?
This was a bug in Xcode and its fixed in the new GM Seed 2 (11A420a).
I encountered this issue as well. I was using Xcode 11 beta 6, with Command Line Tools 11.0.
I solved it by switching to Xcode 10.2.1 and Command Line Tools 10.2.1, cleaning & building again.
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