以前寫了篇 CocoaPods建立私有倉庫 spec repo 總感覺有些凌亂。現(xiàn)在整理下。
1.用處
有的企業(yè)好多項目里會用到相同的功能模塊,但是這些又不希望被別人通用使用;要是多個項目 代碼考來考去的又不便于維護,這個時候用私有Cocoapods 庫 最實用了。
2.建git 項目
如
https://github.com/lizhi0123/NSDictionaryArray_utf8Description
在建項目的時候 選擇MIT證書,因為在建.podspec文件時需要配置 證書。(如下圖)

3.給項目建個tag
4.建.podspec 文件
準備好你的項目文件,實現(xiàn)你功能。
通過命令
$ pod spec create NSDictionaryArray_utf8Description
創(chuàng)建你的 .podspec 文件。其中 NSDictionaryArray_utf8Description 是pod spec 里的 名稱。要替換成你的項目的 pod spec 名稱。
然后 你的項目文件里 就會多個 NSDictionaryArray_utf8Description.podspec 文件。


5 配置你的.podspec
# `pod spec create NSDictionaryArray_utf8Description` 建 NSDictionaryArray_utf8Description.podspec 文件。
# Be sure to run `pod spec lint NSDictionaryArray_utf8Description.podspec' to ensure this is a
Pod::Spec.new do |s|
s.name = "NSDictionaryArray_utf8Description"
s.version = "1.0"
s.summary = "NSDictionary, NSArray UTF8中文 log 輸出."
s.description = <<-DESC
NSDictionary, NSArray UTF8中文 log 輸出。只支持基本類型。
DESC
s.homepage = "https://github.com/lizhi0123/NSDictionaryArray_utf8Description"
s.license = "MIT"
s.author = { "Sunny" => "zhang_zhi_li@163.com" }
s.platform = :ios, "5.0"
s.source = { :git => "https://github.com/lizhi0123/NSDictionaryArray_utf8Description.git", :tag => "#{s.version}" }
s.source_files = "Classes", "Classes/**/*.{h,m}"
s.exclude_files = "Classes/Exclude"
end
6 驗證你的 .podSpec
通過代碼
pod spec lint NSDictionaryArray_utf8Description.podspec
驗證你的配置。

出現(xiàn)綠色文字 NSDictionaryArray_utf8Description.podspec passed validation. 說明驗證通過。
7 添加你的.podSec 到你的repo
通過命令查看你的repo
pod repo list

其中 “Specs-Repo” 是我自己建的庫。怎么建庫我有空的時候,另外寫一篇文章,現(xiàn)在暫且不講述。
通過命令添加 你的.podSec 到你的私有 repo
pod repo push Specs-Repo NSDictionaryArray_utf8Description.podspec --allow-warnings
其中 Specs-Repo 是 repo 名稱,換成你自己的repo.NSDictionaryArray_utf8Description.podspec 也換成你自己的。

此處已經(jīng)完全建成你自己的Cocoapods 私有庫了。
使用
只需在podfile 里添加 souce 就行。
source 'https://github.com/lizhi0123/Specs-Repo.git'
source 'https://github.com/CocoaPods/Specs.git'
其中
https://github.com/lizhi0123/Specs-Repo.git 是我自己私有庫位置。
https://github.com/CocoaPods/Specs.git 是公共庫位置。
注: 添加私有庫時,公共庫必須添加source中。否則公有庫 不能用。

原文地址:http://www.itdecent.cn/p/cc7404997fc5
s.source_files = "Classes/**/*.{h,m}"
s.exclude_files = "Classes/Exclude"
s.resource_bundles = {
'QKChineseVerifyCodeFramework' => ['Classes/**/*.{storyboard,xib,xcassets,json,imageset,png}']
}
謝謝 ,請點贊,手動碼字 不容易。