我有一个cocoapod库,其中包含2种格式的资产:
我的podspec
文件包含资源包的定义:
s.resource_bundle = {'SparkSetup' => ['Resources/**/*.{xcassets,storyboard}']}
Run Code Online (Sandbox Code Playgroud)
我在pod项目中有一个单独的目标,通过使用这些文件+该包的plist文件来创建资源包.
事情是,当我在应用程序项目中使用pod时 - 我可以看到storyboard/xcassets文件位于pod目标中,我可以轻松访问和运行故事板,但故事板中引用的图像(到.xcassets文件)是在运行时未找到(但在IB中正确显示).
我得到的错误是:
Could not load the "spinner" image referenced from a nib in the bundle with identifier "(null)"
Run Code Online (Sandbox Code Playgroud)
我确实在products目录中看到了一个bundle文件.要在故事板中实现VC,我使用:
+(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;
}
Run Code Online (Sandbox Code Playgroud)
这似乎很适合找到故事板,但不适用于在同一捆绑中的.xcassets中查找图像.
我究竟做错了什么?如何从这个故事板/代码中引用图像,并能够将此UI pod集成到任何应用程序中?
谢谢!