我有一个cocoapod库,其中包含2种格式的资源:
- .storyboard文件
- Xcode的asset catalog .xcassets(带图像)
我的podspec
文件包含资源包的定义:
s.resource_bundle = {'SparkSetup' => ['Resources/**/*.{xcassets,storyboard}']}
我在pod项目中有一个单独的目标,通过使用这些文件和一个plist文件创建资源包。
问题是,当我在应用程序项目中使用pod时,我可以看到storyboard /xcassets 文件位于pod目标中,并且可以轻松访问和运行storyboard,但是在运行时找不到storyboard中引用的图像(到.xcassets文件),但在Interface Builder中显示正确。
我得到的错误是:
Could not load the "spinner" image referenced from a nib in the bundle with identifier "(null)"
我在产品目录中看到一个捆绑文件。 在Storyboard中实例化VCs时,我使用以下内容:
+(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;
}
似乎可以很好地找到故事板,但无法在同一捆绑包中的.xcassets中找到图像。
我哪里做错了? 我该如何从故事板/代码引用图像并能够将此UI pod集成到任何应用程序中?
谢谢!
.png
而不是.xcasset
,并逐个引用每个图像。虽然不完美,但这是唯一的可行方式.. - mindbomb