Search code examples
swiftxcodeassetstarget

Swift Color Assets between different targets


I have an app with a couple of different targets. I have create two different asset folders with a set of colors. Both assetfolders have the same names for each color, however different colors.

I am calling the color codes in the code like this: let color = UIColor(named: "primary"). However when I am running the app on a different target, it pulls the primary color from the other target. Both files are only checked to the appropriate target, and unchecked for all other targets.

I am trying to use the same name, with different colors between targets. Does anybody have any tips for me? :)

enter image description here


Solution

  • Guessing that UIColor(named: "primary", in: bundleFromTheRightTarget, compatibleWith: nil) would be enough to disambiguate which place it should load from