'"Image Literal" commands not working in Xcode

I started studying swift language n there is a command Image Literal to add an image but it's not showing up anything. other than that if I try any other coding thing it automatically gets suggested but image literal is not working at all... I am using Xcode 13. Any leads would be really helpful.



Solution 1:[1]

For image literals in Xcode 13 type:

#imageLiteral(

The image literal should be displayed and available for picking the image.

The same appears to work for the other literals:

#colorLiteral(
#fileLiteral(

This places the literal in code without code completion. The code completion stopped working on literals for me as well.

After picking an image, comment the line to see the file name, if needed.

Solution 2:[2]

#imageLiteral(

Without the closing parenthesis, In this way you can add images in Xcode 13.

Solution 3:[3]

Not sure if that's exactly what you're asking about, but... You can add an image to a view with Image() function that takes image file path as argument. You can do all kinds of stuff with it using methods right after the function. This, for example, crops the image into a circle, resizes it, and adds white outline:

Image("<file path>")
    .resizable()
    .frame(width: screenSize.width / 2, 
           height: screenSize.width / 2)
    .clipShape(Circle())
    .overlay(Circle().stroke(Color.white, lineWidth: 5))

Solution 4:[4]


try this: 

1- solutions 

#imageLiteral then it automatically shows the imageFile 
and click on it  that will show the recent image that you have
in the assets file

2- solutions 

UIImage(named: String)
write the image name that you  have in the assets file in the place of String

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pkamb
Solution 2 Mehedi Hasan
Solution 3 scraptechguy
Solution 4