POD上傳自己的庫

一、在Github上創建存儲庫(前提是得有一個Github賬號,如果沒有就註冊一個)

1.在你賬號的首頁的右上方會有新建存儲庫的按鈕,如下圖:

 

 

2.點擊New reposltory進入創建頁面

 


按自己的需求填寫好之後,點擊Create repository來創建這個存儲庫,出現下圖所示,說明創建成功了。

3.將Github上的存儲庫clone到本地
a.命令方式是在終端選好指定的目錄後輸入命令:git clone 工程的網址

b.如果通過GitHub客戶端也是可以的,需要點擊客戶端左上角的加號,然後選擇要clone 的存儲庫

 

選擇需要放置的位置

 

然後點擊clone 即可。

二、將需要cocoapods進行託管的SDK上傳到GitHub存儲庫上且發佈到cocoapods上。
1.將自己的SDK工程拷到之前clone到本地的存儲庫中。

 

2.創建pod 賬號
發佈到cocoapods上你需要有一個pod 的賬號,可以使用pod trunk me 來查看自己的賬號信息,如果沒有賬號的話需要先註冊一下:

 

然後通過郵箱去驗證一下

打開這個地址就可以驗證成功了,此時再輸入命令pod trunk me 就可以看到自己的賬號信息。

3.創建podspec文件
使用終端進入到工程文件的目錄中,在README.md文件所在的位置創建一個podspec 文件,使用pod spec create repositoryDemo

4.編輯podspec文件
因爲新建的podspec是一個包含所有需要填寫信息的文件,其中有很多東西是不需要填就可以的,可以直接copy別人的podspec文件,然後將需要改動的地方作出相應的改動即可。

 

Pod::Spec.new do |s|
  s.name         = "RepositoryDemonstration"    #存儲庫名稱
  s.version      = "0.0.1"      #版本號,與tag值一致
  s.summary      = "a repository demo"  #簡介
  s.description  = "a repository demo"  #描述
  s.homepage     = "https://github.com/xiaowu2016/RepositoryDemonstration"      #項目主頁,不是git地址
  s.license      = { :type => "MIT", :file => "LICENSE" }   #開源協議
  s.author             = { "zhangchao" => "[email protected]" }  #作者
  s.platform     = :ios, "7.0"                  #支持的平臺和版本號
  s.source       = { :git => "https://github.com/xiaowu2016/RepositoryDemonstration.git", :tag => "0.0.1" }         #存儲庫的git地址,以及tag值
  s.source_files  =  "RepositoryDemonstration/Other/**/*.{h,m}" #需要託管的源代碼路徑
  s.requires_arc = true #是否支持ARC
  s.dependency "Masonry", "~> 1.0.0"    #所依賴的第三方庫,沒有就不用寫

end

如果分級目錄:

  spec.source_files  = "iOSWorkingComponents/iOSWorkingComponents/Components/ComponentsHeader.h"
  spec.public_header_files = "iOSWorkingComponents/iOSWorkingComponents/Components/ComponentsHeader.h"
#AppConfig目錄
    spec.subspec 'AppConfig' do |ss|
    ss.source_files = 'iOSWorkingComponents/iOSWorkingComponents/Components/AppConfig/*.{h,m}'
    end

#BaseUI目錄
    spec.subspec 'BaseUI' do |ss|
    ss.dependency 'iOSWorkingComponents/AppConfig'
    ss.source_files = 'iOSWorkingComponents/iOSWorkingComponents/Components/BaseUI/*.{h,m}'
    end

#HUD目錄
    spec.subspec 'HUD' do |ss|
    ss.dependency 'iOSWorkingComponents/AppConfig'
    ss.source_files = 'iOSWorkingComponents/iOSWorkingComponents/Components/HUD/MBProgressHUD+LL/*.{h,m}'
    end

#Categories目錄
    spec.subspec 'Categories' do |ss|
    ss.dependency 'iOSWorkingComponents/AppConfig'
    ss.dependency 'iOSWorkingComponents/HUD'
    ss.source_files = 'iOSWorkingComponents/iOSWorkingComponents/Components/Categories/**/*.{h,m}'
    end

#CalendarView目錄
    #spec.subspec 'CalendarView' do |ss|
    #ss.dependency 'iOSWorkingComponents/Categories'
    #ss.source_files = 'iOSWorkingComponents/iOSWorkingComponents/Components/CalendarView/*.{h,m}'
    #end

 

 

5.設置tag的值,並上傳到GitHub上
(1) git add * (將代碼添加到暫存區)
(2) git commit -m '提交內容' (將代碼提交到本地庫,並寫上簡述)
(3) git tag 'xxx'(設置本地分支的版本,xxx必須是你在 .podspec 文件中的 version(版本號))
(4) git tag (使用此命令查看tag的值是否設置成功)
(5) git push origin master (將本地主幹提交到遠程服務端)
(6) git push origin xxx(將本地XXX版本上傳到GitHub服務器上並設置origin爲XXX)

6.發佈到cocoapods 上進行託管
(1) 先用pod spec lint 驗證podspec 文件

這裏報了個警告,直接使用pod spec lint --allow-warnings來忽略所有警告即可。

介紹:spec.static_framework

是否必須:否
解釋:過
例如:
spec.static_framework = true

依賴的第三方里麪包含了靜態庫,直接修改 podspec,修改依賴項:s.static_framework = true

 

(2) 發佈
輸入 pod trunk push --allow-warnings命令來發布到cocoapods上,這可能需要幾分鐘時間。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章