Xcode 10 - image literals no longer available

后端 未结 9 2096
甜味超标
甜味超标 2020-12-08 03:46

Xcode 10 Release Notes: \"Code Completion for Swift image literals has been removed in Xcode 10\"

So it\'s not a bug that I couldn\'t ad

9条回答
  •  甜味超标
    2020-12-08 04:04

    For the benefit of others with legacy code that utlizes Swift Image Literals, the code and syntax of the image literal function themselves are still valid and work perfectly fine in Xcode 10 with Swift 4.2.

    There is no need to rollback or refactor existing code that utlizes these image literals, and they can still be used as follows:

    imageView.image = #imageLiteral(resourceName: imageNameString)
    

    Only the code completion function (or auto-complete) of the Xcode IDE has been discontinued.


    UPDATE

    The difference in image-literal representation in previous and current versions or Xcode/Swift:

    image = #imageLiteral(resourceName: "flower.jpg")
    

    As the extract illustrates, image literals were represented in-line with thumbnails of their actual image. However, now, only a generic icon is used in its place. Presumably, this goes towards reducing the burden on the IDE, by eliminating the overheads of handling and displaying the in-line thumbnails.

提交回复
热议问题