Xcode 10 - image literals no longer available

后端 未结 9 2067
甜味超标
甜味超标 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 03:59

    Found the Shortcut to open the Media Library Tab:

    ++M

    At this point the official documentation does not cover some use cases at Xcode 10 beta so I'm not able to find a way to move the media part to the old position.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-08 04:05

    i'm using Xcode 10 beta 4 and i have the same problem ! Resolved using the old way to pass an image

    PizzaModel(
                nome: "Marinara",
                ingredienti: "Pomodoro, Aglio",
                calorie: "729",
                img: UIImage(named: "marinara")!
    )
    
    0 讨论(0)
  • 2020-12-08 04:10

    If anyone using Xcode 11 then you can find all media using below option:

    0 讨论(0)
  • 2020-12-08 04:11
    • using UIImage(imageLiteralResourceName: 'imageName') won't return an optional and works just fine
    0 讨论(0)
  • 2020-12-08 04:12

    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 imagem and it work like before!

    0 讨论(0)
提交回复
热议问题