Browse Source

修改获取资源方式

wenweiwei 3 năm trước cách đây
mục cha
commit
f005ccb07c

+ 2 - 2
BFCommonKit.podspec

@@ -8,7 +8,7 @@
 
 Pod::Spec.new do |s|
   s.name             = 'BFCommonKit'
-  s.version          = '1.0.9'
+  s.version          = '1.1.0'
   s.summary          = 'A short description of BFCommonKit.'
   s.swift_version    = '5.0'
 # This description is used to generate tags and improve search results.
@@ -72,7 +72,7 @@ TODO: Add long description of the pod here.
   end
 
    s.resource_bundles = {
-     'BFCommon_Resources' => ['BFCommonKit/Assets/Resources/*.png']
+     'BFCommonKit_Resources' => ['BFCommonKit/Assets/Resources/*.png']
    }
   # s.resources = 'BFCommonKit/Assets/Resources/*.png'
   # s.public_header_files = 'Pod/Classes/**/*.h'

+ 2 - 2
BFCommonKit/Classes/BFBase/Controller/PQBaseViewController.swift

@@ -86,9 +86,9 @@ open class PQBaseViewController: UIViewController, UIGestureRecognizerDelegate {
         leftButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: -5, right: 0)
         if tintColor != nil {
             leftButton.tintColor = tintColor
-            leftButton.setImage(UIImage().BF_Image(named: image ?? "icon_detail_back").withRenderingMode(.alwaysTemplate), for: .normal)
+            leftButton.setImage(UIImage.moduleImage(named: "icon_detail_back", moduleName: "BFCommonKit")?.withRenderingMode(.alwaysTemplate), for: .normal)
         } else {
-            leftButton.setImage(UIImage().BF_Image(named: image ?? "icon_detail_back"), for: .normal)
+            leftButton.setImage(UIImage.moduleImage(named: "icon_detail_back", moduleName: "BFCommonKit"), for: .normal)
         }
         leftButton.addTarget(self, action: #selector(backBtnClick), for: .touchUpInside)
         navHeadImageView?.addSubview(leftButton)

+ 1 - 1
BFCommonKit/Classes/BFBase/View/PQFollowButton.swift

@@ -16,7 +16,7 @@ public class PQFollowButton: UIButton {
         let attenBtn = UIButton(type: .custom)
         attenBtn.isUserInteractionEnabled = false
         attenBtn.setTitle("", for: .selected)
-        attenBtn.setImage(UIImage.init().BF_Image(named: "icon_oder"), for: .selected)
+        attenBtn.setImage(UIImage.moduleImage(named: "icon_oder", moduleName: "BFCommonKit"), for: .selected)
         attenBtn.setTitle("+", for: .normal)
         attenBtn.setImage(nil, for: .normal)
         attenBtn.setTitleColor(UIColor.white, for: .normal)

+ 1 - 1
BFCommonKit/Classes/BFBase/View/PQHeartAnimation.swift

@@ -18,7 +18,7 @@ public class PQHeartAnimation: NSObject {
         }
         let imgV = UIImageView(frame: CGRect(x: point.x - size / 2.0, y: point.y - size / 2.0, width: size, height: size))
         imgV.tag = cHeartTag
-        imgV.image = UIImage.init().BF_Image(named:  "ic_heart")
+        imgV.image = UIImage.moduleImage(named: "ic_heart", moduleName: "BFCommonKit")
         imgV.contentMode = .scaleAspectFill
         baseView.addSubview(imgV)
 

+ 3 - 3
BFCommonKit/Classes/BFBase/View/PQRemindView.swift

@@ -286,10 +286,10 @@ extension PQEmptyRemindView {
             refreshBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#EE0051")
             refreshBtn.setTitleColor(UIColor.white, for: .normal)
             refreshBtn.setTitle("刷新", for: .normal)
-            imageView.image = UIImage.init().BF_Image(named:  "pic_network")
+            imageView.image = UIImage.moduleImage(named: "pic_network", moduleName: "BFCommonKit")
         } else {
             if emptyData?.emptyImage != nil, emptyData?.emptyImage?.count ?? 0 > 0 {
-                imageView.image = UIImage.init().BF_Image(named:  emptyData?.emptyImage ?? "")
+                imageView.image = UIImage.moduleImage(named: emptyData?.emptyImage ?? "", moduleName: "BFCommonKit")
             } else {
                 imageView.image = nil
             }
@@ -297,7 +297,7 @@ extension PQEmptyRemindView {
             remindSubLab.text = emptyData?.summary
             refreshBtn.isHidden = emptyData?.isRefreshHidden ?? true
             if emptyData?.refreshImage != nil, (emptyData?.refreshImage?.count ?? 0) > 0 {
-                refreshBtn.setImage(UIImage.init().BF_Image(named:  emptyData?.refreshImage ?? ""), for: .normal)
+                refreshBtn.setImage(UIImage.moduleImage(named: emptyData?.refreshImage ?? "", moduleName: "BFCommonKit"), for: .normal)
             } else {
                 refreshBtn.setImage(nil, for: .normal)
             }

+ 19 - 1
BFCommonKit/Classes/BFCategorys/BFBundle+Ext.swift

@@ -9,10 +9,15 @@ import Foundation
 
 public extension Bundle {
     // bf main bundle url
+//    func BF_mainbundle_URL() -> URL {
+//        let bundle: Bundle = Bundle(for: PQBaseViewController.self)
+//        return bundle.url(forResource: "BFFramework", withExtension: "bundle")!
+//    }
+
     func BF_mainbundle_URL() -> URL {
         var bundleURL = Bundle.main.url(forResource: "Frameworks", withExtension: nil)
         bundleURL = bundleURL?.appendingPathComponent("BFCommonKit").appendingPathExtension("framework")
-        let bundle: Bundle = Bundle.init(url: bundleURL!)!
+        let bundle: Bundle = Bundle(url: bundleURL!)!
         return bundle.url(forResource: "BFCommon_Resources", withExtension: "bundle")!
     }
 
@@ -20,4 +25,17 @@ public extension Bundle {
     func BF_mainbundle() -> Bundle {
         return Bundle(url: BF_mainbundle_URL())!
     }
+
+    private class func bundleURL(moduleName: String) -> URL? {
+        var bundleURL = Bundle.main.url(forResource: "Frameworks", withExtension: nil)
+        bundleURL = bundleURL?.appendingPathComponent(moduleName).appendingPathExtension("framework").appendingPathComponent("\(moduleName)_Resources").appendingPathExtension("bundle")
+        return bundleURL
+    }
+
+    class func current(moduleName: String) -> Bundle? {
+        guard let url = bundleURL(moduleName: moduleName) else {
+            return nil
+        }
+        return Bundle(url: url)
+    }
 }

+ 5 - 0
BFCommonKit/Classes/BFCategorys/BFUIImage+Ext.swift

@@ -26,6 +26,11 @@ public extension UIImage {
         return image
     }
 
+    class func moduleImage(named: String, moduleName: String) -> UIImage? {
+        let image: UIImage? = UIImage(named: named, in: Bundle.current(moduleName: moduleName), compatibleWith: nil)
+        return image
+    }
+
     func cropImage(ratio: CGFloat) -> UIImage {
         // 计算最终尺寸
         let newSize: CGSize = CGSize(width: size.width, height: size.width * ratio)

+ 3 - 3
BFCommonKit/Classes/BFCategorys/BFUIView+Ext.swift

@@ -375,7 +375,7 @@ public extension UIImageView {
     /// imageView加载网络图片
     /// - Parameters:
     ///   - url: 网络url
-    func setNetImage(url: String?, placeholder: UIImage = UIImage().BF_Image(named: "placehold_image")) {
+    func setNetImage(url: String?, placeholder: UIImage = UIImage.moduleImage(named: "placehold_image", moduleName: "BFCommonKit") ?? UIImage()) {
         if url == nil || (url?.count ?? 0) <= 0 {
             return
         }
@@ -432,7 +432,7 @@ public extension UIButton {
     /// UIButton加载网络图片
     /// - Parameters:
     ///   - url: 网络url
-    func setNetImage(url: String?, placeholder: UIImage = UIImage().BF_Image(named: "placehold_image")) {
+    func setNetImage(url: String?, placeholder: UIImage = UIImage.moduleImage(named: "placehold_image", moduleName: "BFCommonKit") ?? UIImage()) {
         if url == nil || (url?.count ?? 0) <= 0 {
 //            BFLog(message: "设置按钮网络图片地址为空")
             return
@@ -446,7 +446,7 @@ public extension UIButton {
     /// UIButton加载网络背景图片
     /// - Parameters:
     ///   - url: 网络url
-    func setNetBackgroundImage(url: String, placeholder: UIImage = UIImage().BF_Image(named: "placehold_image")) {
+    func setNetBackgroundImage(url: String, placeholder: UIImage = UIImage.moduleImage(named: "placehold_image", moduleName: "BFCommonKit") ?? UIImage()) {
         kf.setBackgroundImage(with: URL(string: url), for: .normal, placeholder: placeholder, options: url.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
 
         }) { _ in

+ 1 - 1
BFCommonKit/Classes/BFUtility/PQCommonMethodUtil.swift

@@ -95,7 +95,7 @@ public func cIPHONE_X() -> Bool {
 /// - Parameters:
 ///   - url: 网络url
 ///   - mainView: 需要加载的视图
-public func netImage(url: String, mainView: Any, placeholder: UIImage = UIImage().BF_Image(named: "placehold_image")) {
+public func netImage(url: String, mainView: Any, placeholder: UIImage = UIImage.moduleImage(named: "placehold_image", moduleName: "BFCommonKit") ?? UIImage()) {
     if mainView is UIImageView {
         (mainView as! UIImageView).kf.setImage(with: URL(string: url), placeholder: placeholder, options: url.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
 

+ 15 - 15
Example/Podfile.lock

@@ -1,25 +1,25 @@
 PODS:
   - Alamofire (4.9.1)
-  - BFCommonKit (1.0.6):
-    - BFCommonKit/BFBase (= 1.0.6)
-    - BFCommonKit/BFCategorys (= 1.0.6)
-    - BFCommonKit/BFConfig (= 1.0.6)
-    - BFCommonKit/BFDebug (= 1.0.6)
-    - BFCommonKit/BFEnums (= 1.0.6)
-    - BFCommonKit/BFUtility (= 1.0.6)
-  - BFCommonKit/BFBase (1.0.6):
+  - BFCommonKit (1.0.9):
+    - BFCommonKit/BFBase (= 1.0.9)
+    - BFCommonKit/BFCategorys (= 1.0.9)
+    - BFCommonKit/BFConfig (= 1.0.9)
+    - BFCommonKit/BFDebug (= 1.0.9)
+    - BFCommonKit/BFEnums (= 1.0.9)
+    - BFCommonKit/BFUtility (= 1.0.9)
+  - BFCommonKit/BFBase (1.0.9):
     - Alamofire (= 4.9.1)
     - BFCommonKit/BFCategorys
     - BFCommonKit/BFConfig
     - BFCommonKit/BFUtility
     - SnapKit (= 5.0.1)
-  - BFCommonKit/BFCategorys (1.0.6):
+  - BFCommonKit/BFCategorys (1.0.9):
     - KingfisherWebP (= 1.3.0)
-  - BFCommonKit/BFConfig (1.0.6)
-  - BFCommonKit/BFDebug (1.0.6):
+  - BFCommonKit/BFConfig (1.0.9)
+  - BFCommonKit/BFDebug (1.0.9):
     - BFCommonKit/BFCategorys
-  - BFCommonKit/BFEnums (1.0.6)
-  - BFCommonKit/BFUtility (1.0.6):
+  - BFCommonKit/BFEnums (1.0.9)
+  - BFCommonKit/BFUtility (1.0.9):
     - Alamofire (= 4.9.1)
     - BFCommonKit/BFCategorys
     - BFCommonKit/BFConfig
@@ -63,7 +63,7 @@ EXTERNAL SOURCES:
 
 SPEC CHECKSUMS:
   Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18
-  BFCommonKit: 6c5a55ae23e9c08b826f26883edfe49c55c01e02
+  BFCommonKit: 9523ec22780f7d5db0d637071ec80a81782bb93e
   KeychainAccess: c0c4f7f38f6fc7bbe58f5702e25f7bd2f65abf51
   Kingfisher: 6c3df386db71d82c0817a429d2c9421a77396529
   KingfisherWebP: dec17a5eb1af2658791bde1f93ae9a853678f826
@@ -71,6 +71,6 @@ SPEC CHECKSUMS:
   SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb
   Toast-Swift: 9b6a70f28b3bf0b96c40d46c0c4b9d6639846711
 
-PODFILE CHECKSUM: f633c46b12fef52fd5badf33e2bef9887c131b39
+PODFILE CHECKSUM: 5c138dc5d174c9336dd4473cb26265c7619334aa
 
 COCOAPODS: 1.10.1

+ 4 - 4
Example/Pods/Local Podspecs/BFCommonKit.podspec.json

@@ -1,10 +1,10 @@
 {
   "name": "BFCommonKit",
-  "version": "1.0.6",
+  "version": "1.0.9",
   "summary": "A short description of BFCommonKit.",
   "swift_versions": "5.0",
   "description": "TODO: Add long description of the pod here.",
-  "homepage": "https://git.yishihui.com/wenweiwei/BFCommonKit",
+  "homepage": "https://git.yishihui.com/wenweiwei",
   "license": {
     "type": "MIT",
     "file": "LICENSE"
@@ -14,13 +14,13 @@
   },
   "source": {
     "git": "https://git.yishihui.com/wenweiwei/BFCommonKit.git",
-    "tag": "1.0.6"
+    "tag": "1.0.9"
   },
   "platforms": {
     "ios": "10.0"
   },
   "resource_bundles": {
-    "BFCommon_Resources": [
+    "BFCommonKit_Resources": [
       "BFCommonKit/Assets/Resources/*.png"
     ]
   },

+ 15 - 15
Example/Pods/Manifest.lock

@@ -1,25 +1,25 @@
 PODS:
   - Alamofire (4.9.1)
-  - BFCommonKit (1.0.6):
-    - BFCommonKit/BFBase (= 1.0.6)
-    - BFCommonKit/BFCategorys (= 1.0.6)
-    - BFCommonKit/BFConfig (= 1.0.6)
-    - BFCommonKit/BFDebug (= 1.0.6)
-    - BFCommonKit/BFEnums (= 1.0.6)
-    - BFCommonKit/BFUtility (= 1.0.6)
-  - BFCommonKit/BFBase (1.0.6):
+  - BFCommonKit (1.0.9):
+    - BFCommonKit/BFBase (= 1.0.9)
+    - BFCommonKit/BFCategorys (= 1.0.9)
+    - BFCommonKit/BFConfig (= 1.0.9)
+    - BFCommonKit/BFDebug (= 1.0.9)
+    - BFCommonKit/BFEnums (= 1.0.9)
+    - BFCommonKit/BFUtility (= 1.0.9)
+  - BFCommonKit/BFBase (1.0.9):
     - Alamofire (= 4.9.1)
     - BFCommonKit/BFCategorys
     - BFCommonKit/BFConfig
     - BFCommonKit/BFUtility
     - SnapKit (= 5.0.1)
-  - BFCommonKit/BFCategorys (1.0.6):
+  - BFCommonKit/BFCategorys (1.0.9):
     - KingfisherWebP (= 1.3.0)
-  - BFCommonKit/BFConfig (1.0.6)
-  - BFCommonKit/BFDebug (1.0.6):
+  - BFCommonKit/BFConfig (1.0.9)
+  - BFCommonKit/BFDebug (1.0.9):
     - BFCommonKit/BFCategorys
-  - BFCommonKit/BFEnums (1.0.6)
-  - BFCommonKit/BFUtility (1.0.6):
+  - BFCommonKit/BFEnums (1.0.9)
+  - BFCommonKit/BFUtility (1.0.9):
     - Alamofire (= 4.9.1)
     - BFCommonKit/BFCategorys
     - BFCommonKit/BFConfig
@@ -63,7 +63,7 @@ EXTERNAL SOURCES:
 
 SPEC CHECKSUMS:
   Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18
-  BFCommonKit: 6c5a55ae23e9c08b826f26883edfe49c55c01e02
+  BFCommonKit: 9523ec22780f7d5db0d637071ec80a81782bb93e
   KeychainAccess: c0c4f7f38f6fc7bbe58f5702e25f7bd2f65abf51
   Kingfisher: 6c3df386db71d82c0817a429d2c9421a77396529
   KingfisherWebP: dec17a5eb1af2658791bde1f93ae9a853678f826
@@ -71,6 +71,6 @@ SPEC CHECKSUMS:
   SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb
   Toast-Swift: 9b6a70f28b3bf0b96c40d46c0c4b9d6639846711
 
-PODFILE CHECKSUM: f633c46b12fef52fd5badf33e2bef9887c131b39
+PODFILE CHECKSUM: 5c138dc5d174c9336dd4473cb26265c7619334aa
 
 COCOAPODS: 1.10.1

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 437 - 437
Example/Pods/Pods.xcodeproj/project.pbxproj


+ 1 - 1
Example/Pods/Target Support Files/BFCommonKit/BFCommonKit-Info.plist

@@ -15,7 +15,7 @@
   <key>CFBundlePackageType</key>
   <string>FMWK</string>
   <key>CFBundleShortVersionString</key>
-  <string>1.0.6</string>
+  <string>1.0.9</string>
   <key>CFBundleSignature</key>
   <string>????</string>
   <key>CFBundleVersion</key>

+ 24 - 0
Example/Pods/Target Support Files/BFCommonKit/ResourceBundle-BFCommonKit_Resources-BFCommonKit-Info.plist

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+  <key>CFBundleDevelopmentRegion</key>
+  <string>en</string>
+  <key>CFBundleIdentifier</key>
+  <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
+  <key>CFBundleInfoDictionaryVersion</key>
+  <string>6.0</string>
+  <key>CFBundleName</key>
+  <string>${PRODUCT_NAME}</string>
+  <key>CFBundlePackageType</key>
+  <string>BNDL</string>
+  <key>CFBundleShortVersionString</key>
+  <string>1.0.9</string>
+  <key>CFBundleSignature</key>
+  <string>????</string>
+  <key>CFBundleVersion</key>
+  <string>1</string>
+  <key>NSPrincipalClass</key>
+  <string></string>
+</dict>
+</plist>

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác