-
目錄
- ios swift 創(chuàng)建framework(一):http://www.itdecent.cn/p/2acd1fbb7537
- ios swift 創(chuàng)建framework(二)Dynamic Library資源圖片image引用:http://www.itdecent.cn/p/deeefdc7714f
- ios swift 創(chuàng)建framework(三)Static Library 調(diào)用資源image:
http://www.itdecent.cn/p/d56e341513b5 - ios swift 創(chuàng)建framework(四)Dynamic Library 使用bundle 調(diào)用資源image等
http://www.itdecent.cn/p/17cd5610daef - ios swift 創(chuàng)建framework(五)Static Library 使用bundle 調(diào)用資源image等
http://www.itdecent.cn/p/e2641e4b1c2e
除了上述二、三 方法調(diào)用資源圖片,還可以用bundle 調(diào)用資源圖片,本文介紹 Static Library 調(diào)用bundle
1.創(chuàng)建Bundle 自己百度,此處省略
2.確認(rèn) framework(LZSDK.framework) Macho-Type 為 Static Library

image.png
3. 重要!!! 在主工程LZSDKDemo ,Targets -> LZSDKDemo -> Build Phases -> Copy Bundle Resources 添加對(duì)應(yīng)的framework(LZSDK.framework)

image.png
4.framework(LZSDK.framework)中添加調(diào)用代碼

image.png
public func static_sdkBundle_image()-> UIImage? {
// class: 庫(kù)里 任意class, static bundle 和 mainBundle 是同一個(gè)
let bundle = Bundle(for: LZSDKManager.self)
let mainBundle = Bundle.main
let path = bundle.path(forResource: "LZSDK", ofType: "bundle", inDirectory: "LZSDK.framework")
if let path = path {
let sdkBundle = Bundle(path: path)
let image = UIImage(named: "love", in: sdkBundle, compatibleWith: nil)
return image
}
return nil
}