製做cocoapods第三方庫實踐

一、在GitHub上建立一個遠程倉庫,並選擇License文件。

二、建立本身的項目,並調整好目錄結構

三、建立.podspec

該文件描述項目的信息。 在項目的目錄下使用終端命令建立 pod spec create PFExtensionios

Pod::Spec.new do |s|

  s.name         = "PFExtension"
  s.version      = "0.0.1"
  s.summary      = "some classes extension"
  s.homepage     = "https://github.com/pengfei2015/PFExtension"
  s.license      = { :type => "MIT" }
  s.author             = { "xxxxxx" => "xxxxxxx@xx.com" }
  s.platform     = :ios
  s.platform     = :ios, "9.0"
  s.source       = { :git => "https://github.com/pengfei2015/PFExtension.git", :tag => "#{s.version}" }
  s.source_files  = "Soureces/*.swift"

end
複製代碼

四、驗證.podspec文件的格式

pod lib lintgit

五、解決驗證的error

一、The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a .swift-version file to set the version for your Pod. For example to use Swift 2.3, run:
`echo "4.0" > .swift-version` // swift版本號
複製代碼
二、WARN | [iOS] license: Unable to find a license file

這是由於本地建立的項目裏沒有license文件,將GitHub上的文件拉下來就行 若是建立遠程倉庫的時候忘記選擇,能夠在首頁建立文件,填入license後,右邊會有模板,選擇建立就行github

六、關聯GitHub

git remote add origin https://github.com/pengfei2015/PFExtension.git
    git push -u origin master
複製代碼

七、建立版本號(tag)

git tag 0.0.1 // git tag -a 0.0.1 -m "備註"
    git push --tags
複製代碼

八、註冊cocoapods

pod trunk register GitHub_email 'user_name' --verbosejson

等待終端顯示成功後登錄郵箱驗證swift

九、提交spec

pod trunk push PFExtension.podspec緩存

十、提示成功後刪除本地緩存的search_index.json

rm ~/Library/Caches/CocoaPods/search_index.jsonbash

相關文章
相關標籤/搜索