cocoapod創(chuàng)建私有 pods 遇到的問題

參考文檔:
1、https://guides.cocoapods.org/making/private-cocoapods
2、https://guides.cocoapods.org/making/getting-setup-with-trunk.html
3、http://www.cocoachina.com/ios/20150228/11206.html
4、http://m.itdecent.cn/p/95cee84240a8
5、http://m.itdecent.cn/p/815fc21b9d0d
6、http://m.itdecent.cn/p/4b63dfbd8be7

報錯信息
4、http://www.veryitman.com/2016/11/01/Cocoapods-管理開源項目.html
5、https://github.com/CocoaPods/CocoaPods/issues/5320
6、http://www.itdadao.com/articles/c15a597735p0.html [CocoaPod]基于私有倉庫的pod創(chuàng)建問題
7、https://github.com/CocoaPods/CocoaPods/issues/4887

一、REPO
用于存放 spec 的倉庫??梢詤⒖脊俜轿臋n:https://guides.cocoapods.org/making/private-cocoapods

1、創(chuàng)建 Repo

$ pod repo add REPO_NAME SOURCE_URL

$ pod repo push REPO_NAME SPEC_NAME.podspec

2、刪除 REPO

pod repo remove [name]

二、創(chuàng)建 倉庫 Spec。
1、

pod lib create SPEC_NAME
例如:
pod lib create 
DDJSON.podspec

2、修改 *****.podspec

#
# Be sure to run `pod lib lint DDJSON.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a 
# are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = 'DDJSON'  
  s.version          = '0.1.0'
  s.summary          = 'DDJSON.'
# This description is used to generate tags and improve search results.
#   * Think: What does it do? Why did you write it? What is the focus?
#   * Try to keep it short, snappy and to the point.
#   * Write the description between the DESC delimiters below.
#   * Finally, don't worry about the indent, CocoaPods strips it!       

  s.description      = <<-DESC
                   
DESC 

  s.homepage         = 'https://github.com/<GITHUB_USERNAME>/DDJSON'  
# s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { ‘***' => ‘*****@***.com' }
  s.source           = { :git => 'https://github.com/<GITHUB_USERNAME>/DDJSON.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
  s.ios.deployment_target = '7.0'

# 重點要修改,默認的 s.source_files = 'DDJSON/**/*’,會報 “undefined method `path' for nil:NilClass
”錯誤。
  s.source_files = 'DDJSON/**/*.{c,h,hh,m,mm}'s.public_header_files = 'DDJSON/**/*.h'
  # s.resource_bundles = {
  #   'DDJSON' => ['DDJSON/Assets/*.png']
  #  數(shù)據(jù)庫文件必須要加載 resource 里面,否則 pod install 不會加載到。
  'DDUserTracking' => ['DDUserTracking/*.{xcdatamodeld,xcdatamodel}'] 
  # }

  # s.frameworks = 'UIKit', 'MapKit'
  # CoreData 必須添加引用。
  s.frameworks = 'Foundation', 'CoreData','UIKit'
  # s.dependency 'AFNetworking', '~> 2.3'end

3、驗證

pod lib lint

遇到的問題:
1)“- ERROR | [iOS] unknown: Encountered an unknown error (undefined method `path' for nil:NilClass) during validation.”

參考:https://github.com/CocoaPods/CocoaPods/issues/4887
需要把
s.source_files = 'Pod/Classes/**/*’ 改為 s.source_files = 'Pod/Classes/**/*.{c,h,hh,m,mm}'

IMO this is a configuration error, although we should handle it more gracefully. It's a configuration error because we're saying that a resource is a source file, which it's not. The easy fix here is to change s.source_files = 'Pod/Classes//'
to be something like s.source_files = 'Pod/Classes/
/.{c,h,hh,m,mm}'.

2)``“Encountered an unknown error (Simulator iPhone 4s is not available.) during validation.”``
    升級 cocoapods,“sudo gem install -n /usr/local/bin cocoapods”

4、發(fā)布

# 發(fā)布到 github。

$ pod trunk register orta@cocoapods.org 'Orta Therox' --description='macbook air’

# 發(fā)布到私有庫

pod repo push REPO [NAME.podspec].

# Adding other people as contributors

$ pod trunk add-owner ARAnalytics kyle@cocoapods.org

5、私有庫 中 引用私有庫

即在Podspec
文件中依賴(dependency)私有庫
這種情況就比較麻煩一點,因為畢竟Podspec
文件中并沒有指明私有倉庫地址的地方。那么肯定就不在Podspec
文件里面指明私有倉庫的地方。而是在驗證和上傳私有庫的時候進行指明。即在下面這兩條命令中進行指明:

pod lib lint 項目名.podspec --sources=https://github.com/CocoaPods/Specs.git,192.168.0.100:Plutoy/Specs.git

pod repo push REPO --source=https://github.com/CocoaPods/Specs.git,192.168.0.100:Plutoy/Specs.git 項目名.podspec

要不然你在檢驗項目以及提交項目過程中就會出現(xiàn)Error的情況。
但是這兩種情況還是有點不同的,第一種情況是可以采用開發(fā)者模式,而第二種情況不能采用開發(fā)者模式,只能通過打tag之后才能進行使用,所以在使用第二種情況下最好是測試好之后打完tag再進行引用。

6、刪除某一個 podspec
只需要到私有REPO 目錄下刪除 podspec 即可

cd ~/.cocoapods/repos/DDSpecs
rm -Rf PodTestLibrary

# 任何推送到遠端

git add —all .
git ci -m 
"remove unuseful pods"

git push origin master

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容