I have a cocoapod library which contains assets in 2 formats:
- a .storyboard
- XCode asset catalog .xcassets (with images)
my podspec
file contains the definition for the resource bundle:
s.resource_bundle = {'SparkSetup' => ['Resources/**/*.{xcassets,storyboard}']}
and I have a separate target in the pod project to create a resource bundle by using those files + a plist file for that bundle.
thing is that when I use the pod in an app project - I can see the storyboard/xcassets files being in the pod target and I can access and run the storyboard easily but the images referenced in the storyboard (to the .xcassets file) are not found in run-time (but displayed correctly in IB).
Error I get is:
Could not load the "spinner" image referenced from a nib in the bundle with identifier "(null)"
I do see a bundle file in the products directory.
To instanciate VCs in the storyboard I use:
+(NSBundle *)getResourcesBundle
{
NSBundle *bundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"SparkSetup" withExtension:@"bundle"]];
return bundle;
}
+(UIStoryboard *)getSetupStoryboard
{
UIStoryboard *setupStoryboard = [UIStoryboard storyboardWithName:@"setup" bundle:[SparkSetupMainController getResourcesBundle]];
return setupStoryboard;
}
which seems to work well for finding the storyboard, but not for finding images in the .xcassets in the same bundle.
What am I doing wrong? how can I reference images from this storyboard/from code and be able to integrate this UI pod into any app?
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…