52

Xcode 8 has this new feature that is supposed to suggest image file names when you use UIImage(named:)

In my case it suggests image names even when it doesn't make any sense.

Example:

Example autocomplete image

There is nothing in preferences. I wonder if there is some secret command to disable this part of autocompletion.

3
  • 1
    Did you figure this out? This is super annoying and non productive. Why would I need images in my code?!! It should activate only when opening a UIImage instance :\
    – TruMan1
    Oct 22, 2016 at 1:33
  • No I didn't find how to fix this yet. Oct 26, 2016 at 9:43
  • Fixed in Xcode 10.
    – Cœur
    Sep 27, 2018 at 5:43

3 Answers 3

35
+100

No this unfortunately can't be turned off, and nothing states that this is fixed in the Xcode 8.1 Release Notes.

It should either be fixed or you should have the opportunity to turn it off. The functionality is kind of good when it´s used for it´s purpose only, as I describe in this post.

But the issue is that Xcode 8 is inserting images inline in source when it can't possibly make any sense as you mention. For example, if you have a for iteration and type for x in to start a loop and you have any image in the project whose name matches "in" using this syntax.

Annoying issue, that I hope Apple will fix soon, because the feature is good when it´s used for images only.

Update:
Just confirmed that this is still an issue in Xcode 8.1 stable version.

Update:
This functionality remains in Xcode Version 9.0 beta 6 (9M214v) enter image description here

Update

This seems to be fixed in Xcode 10 now.

5
  • Maybe it can be moved to another target and switched off from there?
    – Nike Kov
    Dec 2, 2016 at 13:20
  • 33
    This issue becomes even more infuriating when the rest of autocomplete functionality fails to work and the images are there just taunting you. "I bet you expected contextually appropriate auto complete options here? HAHA have some images!" I would be happier with the middle finger emoji to be honest.
    – thexande
    Jan 5, 2017 at 18:19
  • 8
    adding refactoring for swift? no, that is hard! let's spend months of coding for inline images, that's a useful feature! Mar 13, 2017 at 11:25
  • 2
    It's 2018, XCode 9.3 (9E145) and the issue still persists. Apr 15, 2018 at 15:47
  • The related problem of "how to stop image literals being displayed as pictures" is still very much there in Xcode 10.
    – Shayne
    Sep 27, 2018 at 8:53
2

It seems to me that the best way to deal with this issue is by using comments (commmand + /). Changing the code to become a comment seems to turn off the autocomplete for image names.

So, you would have basically to switch back and forth between commenting and uncommenting your code (e.g. you find an error, make your code as a comment, fix the error, uncomment your code, check if your changes fixed the issue, and so on.).

Example of the same code with and without being a comment. The line of code with and without a comment

1
  • This allows me to see the code behind the image and is what I needed.
    – Brian Ball
    Jan 13, 2020 at 0:15
1

Simply update to Xcode 10: the image autocompletion feature has been discontinued:

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

Source: the Xcode 10 Beta release notes (this note was removed in the final release notes)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.