美文网首页
Cocopods私有库创建(gitLab)(资源包)

Cocopods私有库创建(gitLab)(资源包)

作者: fanren | 来源:发表于2020-06-07 20:36 被阅读0次

    一、私有库中使用图片(WIIVersionBusiness为例)

    1、在Assets文件夹中存放图片资源

    2、在WIIVersionBusiness.podspec中导入资源

      s.resource_bundles = {
        'WIIVersionBusiness' => ['WIIVersionBusiness/Assets/*.png']
      }
    

    3、在私有库中使用图片

    extension Bundle {
      public static func customFor(framework: String) -> Bundle? {
            var path = Bundle.main.path(forResource: "Frameworks", ofType: nil) ?? ""
            path += "/\(framework).framework/\(framework).bundle"
            return Bundle(path: path)
        }
    }
    
    extension UIImage {
        static public func bundleImage(framework: String, name: String) -> UIImage? {
            let bundle = Bundle.customFor(framework: framework)
            return UIImage(named: name, in: bundle, compatibleWith: nil)
        }
    }
    
    let image = UIImage.bundleImage(framework: "WIIVersionBusiness", name: "n_version_bg")
    

    二、在私有库中使用其他库(以高德地图SDK为例)
    1、在Vendors下保存地图SDK


    2、在WIIMapFrame..podspec中导入资源

      s.source_files = 'WIIMapFrame/Classes/**/*'
      s.public_header_files = 'WIIMapFrame/Classes/**/*.h'
      s.frameworks = 'CoreTelephony', 'SystemConfiguration', 'Security', 'GLKit', 'CoreLocation', 'ExternalAccessory'
      s.libraries = 'c++', 'z'
      s.vendored_frameworks = 'WIIMapFrame/Vendors/*.framework'
      s.preserve_paths = 'WIIMapFrame/Vendors/*.framework'
      s.resources = 'WIIMapFrame/Vendors/MAMapKit.framework/AMap.bundle'
    
      s.pod_target_xcconfig = {
    #'FRAMEWORK_SEARCH_PATHS' => '${PODS_ROOT}/WIIMapFrame/Vendors',
                'HEADER_SEARCH_PATHS' => '$(PODS_ROOT)/WIIMapFrame/Vendors/*.framework/Headers',
                'LD_RUNPATH_SEARCH_PATHS' => '$(PODS_ROOT)/WIIMapFrame/Vendors/',
                'OTHER_LDFLAGS' => '-ObjC'
      }
    

    相关文章

      网友评论

          本文标题:Cocopods私有库创建(gitLab)(资源包)

          本文链接:https://www.haomeiwen.com/subject/wttdzctx.html