Anand Suthar1987 Anand Suthar1987 - 7 months ago 29
Swift Question

WKImage always return nil

Access assets image will always return nil, below is my code and assets catalog screen shot.

let image = WKImage(imageName: "sample")

This will always prints nil.

enter image description here

Update: Updated screen shot


I found that from your screenshot you are setting the Image Set in Assests.xcassets in the swiftWatch WatchOS target and i think you are use that image for the WKDemo target so you get that nil.

Set that Image Set in your WKDemo's Assests.xcassets instead of WatchOS's Assests.xcassets then check.

That issue is your are setting ImageSet in different Target and your are try to load in Different Target.


After checking your sample project you are doing wrong code for getting image. Instead of let image = WKImage(imageName: "sample") you must be use WKPickerItem() object like following code:

 for i in 1...10 {
            let item = WKPickerItem()
            item.title = "Picker itme =\(i)"
            item.contentImage = WKImage(imageName: "sample")

            if let image = item.contentImage


enter image description here