Xcode 13 SwiftUI Color Literal missing

Viewed 8755

I am using the Xcode 13 beta and noticed the Color Literal suggestion when trying to choose a color with a picker does not show up (in previous versions I would do Color(Color Literal()) and a color picker would show up. Any thoughts on this?

3 Answers

Just type #colorLiteral( for color or #imageLiteral( for image and it will appear immediatly

Edit (September 26, 2021): As of Xcode 13.0 (13A233), color literals seem to be working now.


It's a known issue. From the release notes:

#colorLiteral, #imageLiteral, and #fileLiteral aren’t rendered. (75248191)

But other than that, note that init(_ color: UIColor) is deprecated, so you can't do something like Color(UIColor.blue). This applies to color literals too.

Instead, use the new init(uiColor: UIColor).

Solved like this in Xcode 13.4: Put a SPACE after "=" when assigning. Yes, it's that ridiculous. Then double click to pick a color. So:

var someColor = #colorLiteral(

After that can select a color.

Related