Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting images from Cocoapod's xcassets doesn't work

I am using the 1Password Pod and the GCast pod and they both have xcassets files with the assets they want you to use. When I create a button in IB and assign it the name of one of the images in the xcassets file, the correct image shows up but on run-time i get a debug error of: Could not load the "onepassword-button" image referenced from a nib in the bundle with identifier "com.myApp.App"

Any idea what i need to do? Thanks

like image 601
Mark Bourke Avatar asked Nov 09 '22 17:11

Mark Bourke


1 Answers

The only way to resolve this that I've found is to specify the image programmatically, not in Interface Builder:

let bundle = NSBundle(forClass: OnePasswordExtension.self)
let image = UIImage(named: "OnePasswordExtensionResources.bundle/onepassword-button", inBundle: bundle,
                    compatibleWithTraitCollection: nil)

Note that you still need to specify the full path to the resource bundle in UIImage initializer, as the bundle value is not the resource bundle itself, but the container framework bundle.

like image 149
Max Desiatov Avatar answered Nov 15 '22 05:11

Max Desiatov