How to use Image Literal in Xcode 13

Viewed 22377

The most used feature is missing in Xcode 13

Image Literal

#imageLiteral()

these commands do not seem to be working. A similar change has happened for Color Literals as well.

4 Answers

There is no longer image literal :(

You may try:

Who.What = UIImage(named: "catImage")

I came up with a workaround

Create code snippets for color literal and image literal like below

Color

#colorLiteral()

colorLiteral

And add completion shortcut as you want, Example: colorLiteral. Do same for Image literal

Image

#imageLiteral()

imageLiteral

And add completion shortcut as you want. Call those completion shortcuts in your code to get color and image literals.

colorLiteral imageLiteral

type Who.What = #imageLiteral( Currently it works like this.

I used

UIImage(imageLiteralResourceName: "image_asset_name")

and it works perfectly fine on XCode 13.2.1

Related