Getting images from Cocoapod xcassets not working

I use 1Password Pod and the GCast module, and both of them have xcassets files with assets that they want to use. When I create a button in IB and give it the name of one of the images in the xcassets file, the correct image appears, but at runtime I get a debugging error: 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

+5
source share
1 answer

The only way to resolve this that I found is to specify the image programmatically and 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 set in the UIImage initializer, since the bundle value is not the resource package itself, but the package of the container structure.

+1
source

Source: https://habr.com/ru/post/1245941/


All Articles