ios swift 创建framework(四)Dynamic
2022-04-25 本文已影响0人
荔枝lizhi_iOS程序猿
-
目录
- ios swift 创建framework(一):https://www.jianshu.com/p/2acd1fbb7537
- ios swift 创建framework(二)Dynamic Library资源图片image引用:https://www.jianshu.com/p/deeefdc7714f
- ios swift 创建framework(三)Static Library 调用资源image:
https://www.jianshu.com/p/d56e341513b5 - ios swift 创建framework(四)Dynamic Library 使用bundle 调用资源image等
https://www.jianshu.com/p/17cd5610daef
除了上述二、三 方法调用资源图片,还可以用bundle 调用资源图片,本文介绍 Dynamic Library 调用bundle
1.创建Bundle 自己百度,此处省略
2.确认 framework(LZSDK.framework) Macho-Type 为 Dynamic Library
image.png3.在framework中调用资源
image.pngpublic func dynamic_sdkBundle_image()-> UIImage? {
// class: 库里 任意class, dynamic bundle 和 mainBundle 不是同一个
let bundle = Bundle(for: LZSDKManager.self)
let mainBundle = Bundle.main
let path = bundle.path(forResource: "LZSDK", ofType: "bundle")
if let path = path {
let sdkBundle = Bundle(path: path)
let image = UIImage(named: "love", in: sdkBundle, compatibleWith: nil)
return image
}
return nil
}