-
目录
- 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 - ios swift 创建framework(五)Static Library 使用bundle 调用资源image等
https://www.jianshu.com/p/e2641e4b1c2e
除了上述二、三 方法调用资源图片,还可以用bundle 调用资源图片,本文介绍 Static Library 调用bundle
1.创建Bundle 自己百度,此处省略
2.确认 framework(LZSDK.framework) Macho-Type 为 Static Library

3. 重要!!! 在主工程LZSDKDemo ,Targets -> LZSDKDemo -> Build Phases -> Copy Bundle Resources 添加对应的framework(LZSDK.framework)

4.framework(LZSDK.framework)中添加调用代码

public func static_sdkBundle_image()-> UIImage? {
// class: 库里 任意class, static bundle 和 mainBundle 是同一个
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
}
网友评论