// // Bundle+Ext.swift // BFFramework // // Created by ak on 2021/6/2. // 取 BFFramework 资源目录 import Foundation public extension Bundle { // bf main bundle url // func BF_mainbundle_URL() -> URL { // let bundle: Bundle = Bundle(for: BFBaseViewController.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(url: bundleURL!)! return bundle.url(forResource: "BFCommonKit_Resources", withExtension: "bundle")! } // bf main bundle func BF_mainbundle() -> Bundle { return Bundle(url: BF_mainbundle_URL())! } private class func bundleURL(moduleName: String,isAssets: Bool = true) -> URL? { if isAssets { var bundleURL = Bundle.main.url(forResource: "Frameworks", withExtension: nil) bundleURL = bundleURL?.appendingPathComponent(moduleName).appendingPathExtension("framework").appendingPathComponent("\(moduleName)_Resources").appendingPathExtension("bundle") return bundleURL } else { return Bundle.main.url(forResource: "\(moduleName)_Resources", withExtension: "bundle") } } class func current(moduleName: String,isAssets: Bool = true) -> Bundle? { guard let url = bundleURL(moduleName: moduleName,isAssets: isAssets) else { return nil } return Bundle(url: url) } }