我一直在爲如何加載cocoapods resource_bundle中的資源而苦苦掙扎。如何在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。
這樣不行,只是複製這些資源到你的項目,因爲這些資源在吊艙可隨時更新/刪除。 –
這個吊艙由我們自己維護。項目規模越來越大,我們希望將每個模塊分開。 –