UIColor(named: ) not working Version 9.0 beta 6 (9M214v)

In the latest beta (6) of xcode 9 and iOS 11 I can no longer access UIColors from the .xcassets folder with UIColor(named: )

Application crashes with no useful output in thr debugger to suggest why

Anyone else having this issue?

Answered by anils in 256682022

Seems to work fine


Here is the color contents.json

{
  "info" : {
    "version" : 1,
    "author" : "xcode"
  },
  "colors" : [
    {
      "idiom" : "universal",
      "color" : {
        "color-space" : "srgb",
        "components" : {
          "red" : "0.686",
          "alpha" : "1.000",
          "blue" : "0.670",
          "green" : "1.000"
        }
      }
    }
  ]
}


Here is the code:

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor(named: "myGreen")
    }
Accepted Answer

Seems to work fine


Here is the color contents.json

{
  "info" : {
    "version" : 1,
    "author" : "xcode"
  },
  "colors" : [
    {
      "idiom" : "universal",
      "color" : {
        "color-space" : "srgb",
        "components" : {
          "red" : "0.686",
          "alpha" : "1.000",
          "blue" : "0.670",
          "green" : "1.000"
        }
      }
    }
  ]
}


Here is the code:

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor(named: "myGreen")
    }

Thats identical to mine yet im getting a crash. Thanks for confirming though.

UIColor(named: ) not working Version 9.0 beta 6 (9M214v)
 
 
Q