1. 程式人生 > >cocoapods 解除安裝、安裝

cocoapods 解除安裝、安裝

1、解除安裝

a、解除安裝老版本cocoapods
$ sudo gem uninstall cocoapods
b、檢視本地安裝過的cocopods相關東西
$ gem list --local | grep cocoapods
顯示如下:
cocoapods (1.0.1)
cocoapods-core (1.0.1)
cocoapods-deintegrate (1.0.1)
cocoapods-downloader (1.1.1)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.0.0)
cocoapods-try (1.1.0)
然後使用命令逐個刪除
$ sudo gem uninstall cocoapods-core
$ sudo gem uninstall cocoapods-deintegrate

2、安裝

a、更換源,並且更新Mac上的Ruby
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
注:檢視源路徑是否更換gem sources -l (請確保只有 gems.ruby-china.com
sudo gem update --system

b、安裝cocoapods
sudo gem install cocoapods
注如果報錯執行 sudo gem install -n /usr/local/bin cocoapods

c、cocoapods的使用
1、版本檢視: pod --version
2、查詢 pod search “AFNetworking”
3、專案使用:
a、終端:cd 專案目錄
b、終端: pod init
c、開啟專案 podfile檔案編輯
b、pod install/ pod update

podfile檔案模板:

# Uncomment the next line to define a global platform for your project
platform :ios, '8.0'
use_frameworks!  //動態庫
inhibit_all_warnings!  //忽略waring
target 'cocoapodsUse' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for cocoapodsUse

  target 'cocoapodsUseTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'cocoapodsUseUITests' do
    inherit! :search_paths
    # Pods for testing
  end

  pod 'AFNetworking', '~> 3.1.0'
  pod 'SDWebImage', '~> 4.0.0'
end

注:
pod install 和 pod update 區別
install :安裝podfile.lock中鎖定的版本的pods;
update:會更新到最新版本或者podfile中指定版本

解決安裝第三方庫慢的方法(推薦)
pod install --no-repo-update
pod update --no-repo-update


擴充套件
CocoaPods本地私有庫的使用和CocoaPods遠端私有庫的使用
https://www.cnblogs.com/hs-funky/p/6759977.html