Should #imageLiteral work when building in InterfaceBuilder?

I have some code in a custom view that uses #imageLiteral(). This crashes Interface Builder.


Should it be working?


I've changed my code to use UIImage(named:,in:,compatibleWith:) and this resolved my issue but it took some time to find out that this was causing my problem since everything worked fine in the simulator and it took some view debuggin in InterfaceBuilder to eventually find out that this was the problem.

Accepted Reply

No it shouldn't. It's a known bug I've talked to Apple engineers about and they still haven't fixed it or the poor diagnostics.

Replies

This is the syntax:


let image =  #imageLiteral(resourceName: "ImageName") //where imageName is in assets catalog as png

But in fact, jou just need to type

let image =  ImageName


And autocompletion will replace by the picture iself ; behing the hood, the code is let image = #imageLiteral(resourceName: "ImageName")


Can read a detailed discussion here :

h ttps://stackoverflow.com/questions/39610994/xcode-8-image-completion

No it shouldn't. It's a known bug I've talked to Apple engineers about and they still haven't fixed it or the poor diagnostics.