【发布时间】:2016-02-29 05:00:40
【问题描述】:
我为如何在 cocoapods resource_bundle 中加载资源做了很多努力。
以下是我放在.podspecs 文件中的内容。
s.source_files = 'XDCoreLib/Pod/Classes/**/*'
s.resource_bundles = {
'XDCoreLib' => ['XDCoreLib/Pod/Resources/**/*.{png,storyboard}']
}
这就是我试图从主项目中做的事情。
let bundle = NSBundle(forClass: XDWebViewController.self)
let image = UIImage(named: "ic_arrow_back", inBundle: bundle, compatibleWithTraitCollection: nil)
print(image)
我确实在XDCoreLib.bundle 中看到了图片,但它返回 nil。
【问题讨论】:
-
不要那样做,只需将这些资源复制到您的项目中,因为 pod 中的这些资源可以随时更新/删除。
-
这个pod是我们自己维护的。项目规模越来越大,我们想把各个模块分开。