ios 静态库.a转framework

以腾讯信鸽推送为例子。
以下为静态库pod QQ_XGPush

Pod::Spec.new do |spec|
  spec.name                     = "QQ_XGPush"
  spec.version                  = "3.2.2"
  spec.summary                  = "腾讯信鸽(XG Push)"
  spec.homepage                 = "http://xg.qq.com"
  spec.authors                  = "tencent TEG"
  spec.license                  = "MIT"
  spec.platform                 = :ios, "6.0"
  spec.frameworks               = "CFNetwork", "SystemConfiguration", "CoreTelephony", "CoreGraphics", "Foundation", "UserNotifications"
  spec.libraries                = "z", "sqlite3"
  spec.source                   = { :git => "https://github.com/xingePush/XGPush.git", :tag => spec.version }
  spec.source_files             = "XGPush/*.h"
  spec.vendored_libraries       = "XGPush/*.a"
end

1.关键语法spec.prepare_command
2.新建一个XGPush_Swift.podspec,修改XGPush 原来的podspec内容,最后通过“spec.prepare_command”增加新建.m文件
的命令
3.cocoapod会检测库是否含有.m文件还是仅仅含有静态库来决定是否打包成framework。
以下为静态库.a转为framework, pod例子:XGPush_Swift

Pod::Spec.new do |spec|
  spec.name           = "XGPush_Swift"
  spec.version          = "3.2.4"
  spec.summary          = "腾讯信鸽(XG Push)"
  spec.homepage         = "http://xg.qq.com"
  spec.authors          = "tencent TEG"
  spec.license          = "MIT"
  spec.platform         = :ios, "6.0"
  spec.frameworks       = "CFNetwork", "SystemConfiguration", "CoreTelephony", "CoreGraphics", "Foundation", "UserNotifications"
  spec.libraries        = "z", "sqlite3"
  spec.source         = { :git => "https://github.com/xingePush/XGPush.git" }
  spec.source_files       = "XGPush/*.h","XGPush/Read.m"
  spec.vendored_libraries   = "XGPush/*.a"
  spec.xcconfig            = { "LIBRARY_SEARCH_PATHS" => "\"$(PODS_ROOT)/XGPush_Swift/**\"" }
  spec.static_framework = true

  spec.prepare_command = <<-EOF
    touch XGPush/Read.m
    cat <<-EOF > XGPush/Read.m
    //framework module QQ_XGPush {
    //  header "XGPush.h"
    //  export *
    //  link "z"
    //  link "sqlite3"
    //}
    \EOF
  EOF
end

推荐阅读更多精彩内容