While @Renatus answer is perfectly valid and addresses the core issue (bundle for framework needs to be specified), I wanted to post the solution I went with since it's slightly more direct:
Swift 3.0/4.0/5.0
let image = UIImage(named: "YourImage", in: Bundle(for: YOURFRAMEWORKCLASS.self), compatibleWith: nil)
Alternatively, you can use this pattern for non-class
, aka non-"static", functions:
let image = UIImage(named: "YourImage", in: Bundle(for: type(of: self)), compatibleWith: nil)
or this pattern for class
functions:
let image = UIImage(named: "YourImage", in: Bundle(for: self), compatibleWith: nil)
These alternatives are better for cutting and pasting.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…