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

猜你喜欢

转载自blog.csdn.net/heqiang2015/article/details/84315737
今日推荐