I am currently updating a project to use image literals
, to enjoy the benefits of non-optional images. The project is importing various frameworks, and the frameworks are containing images.
In the frameworks, we had to declare an extension on UIImage
to override the initialiser, because it was looking for the image in the wrong bundle. We did something like:
extension UIImage {
convenience init?(framework_named imageName: String) {
let bundle = Bundle(for: ClassNameInFramework.self)
self.init(named: imageName, in: bundle, compatibleWith: nil)
}
}
I am wanting to use image literals in the framework too, but like before, the literals are looking for the wrong bundle for the image and the application crashes.
Does anyone know, how to specify the image literal to which bundle to look for the image?
init(named:)
initializer which looks in the main bundle.