Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image suggestions are not working Xcode 10

I am trying to set image to UIImageView. Its working well in older version.

In Xcode 9.4.1

enter image description here

But in Xcode 10

enter image description here

When I am trying to type name of image, image suggestion is not showing.

Even "Image Literal" is not working. Double clicking on above icon also not working.

Is there any setting in Xcode preferences?

How to enable image suggestion like before?

like image 570
Jay Patel Avatar asked Jul 05 '18 12:07

Jay Patel


3 Answers

In Xcode 10 and Swift 4.2, only the code completion function (or auto-complete) of the Xcode IDE has been discontinued for the old way. Here is the new way:

Just type image literal and it will complete with default icon. Double click on this icon and it will open the media library right side of it.

Just choose your image and it work like before!

Hope I am able to help you!

like image 147
Mohd Asim Avatar answered Nov 16 '22 01:11

Mohd Asim


https://download.developer.apple.com/Developer_Tools/Xcode_10_beta_3/Release_Notes_for_Xcode_10_beta_3.pdf

Code Completion for Swift image literals has been removed in Xcode 10. (38087260) enter image description here

like image 22
user2481332 Avatar answered Nov 16 '22 01:11

user2481332


There seem to be some real issues with how Xcode 10 handles image literals, especially when the name you provide your assets doesn't align with the filename of those assets.

The following are the steps I've found will restore image literal previews.

Add an image via the media library picker.

Add an image via the media library picker.

If you have multiple resolutions for your image (e.g. @1x, @2x, @3x), Xcode will inconveniently drop them all into your code and throw an error to let you know you've done something naughty.

Consecutive statements error.

Delete two of the faulty image previews, if necessary. You may be left with a default image icon instead of a preview of your actual image.

Default image icons.

Comment out the lines on which you're setting the image. You'll see the image literal references the filename of your asset rather than the name you've provided in the asset catalog.

If you've renamed your assets after adding them to your asset catalog, this seems to sometimes prevent Xcode from reading the asset appropriately.

Filenames.

Change the filenames to the appropriate asset names.

You can find the asset names in your asset catalog.

Asset names in catalog.

Asset names in code.

Uncomment the code and, if the default image icon is still visible, double click on the image icon. It should then display a preview of your actual asset.

You may also need to clean and rebuild your project.

Asset previews.

like image 33
Ian Rahman Avatar answered Nov 16 '22 03:11

Ian Rahman