solution: Image Literal is not working anymore in Xcode

I am pretty much sure that you have reached this page because you are not able to see the Image Literal option anymore in Xcode Swift.

I will give you the best alternative way to achieve the same without having the Image Literal pick-up image option.

In previous versions of Xcode, there was an option like Image Literal. I was trying to do the same after following an Xcode tutorial. But when I started typing Image Literal, the Xcode was not bringing any option like that.

 

Thus, I search over the internet and found that Apple has removed that option from Xcode. Also, I came to know that we can do a similar thing using some other methods. But I will not give you multiple solutions. I will only show you the one which I followed. I hope this will be much easier for you.

 

For me it worked:

UIImage(named: "YourImageName" )

Where you were intending to type ImageLiteral, just don’t do that, and instead of that type the above code.

The image name should be given as a string thus it is necessary to use double quotes around your Image Name.

You can find the image names also in the Assets.

I was trying to do something from a tutorial and in my case, I had to write the below code:

diceImageViewOne.image = UIImage(named: "DiceSix" )

The format is like who.what = UIImage(named: “ImageName” )

Here I wanted to change the image of diceImageViewOne to DiceSix.

If you come up with any better solution please write that in the comment section to help others developers.

One response to “solution: Image Literal is not working anymore in Xcode”

  1. Anar Abbas says:

    Thank you for the answer. I have one more question, how can we create a series and name multiple photos there?

Leave a Reply

Your email address will not be published. Required fields are marked *