安装 cocoapods 第三方管理工具步骤

来源:互联网 发布:python 图片相似度 库 编辑:程序博客网 时间:2024/06/17 17:29
ruby
 
具体流程
  1. 查询资源  gem sources - l    
  2. lanou3gdeMac-mini:~ lanou3g$ gem sources - l
    *** CURRENT SOURCES ***

    https://rubygems.org/

2.不能更新执行就移除  gem sources —remove https://rubygems.org/
lanou3gdeMac-mini:~ lanou3g$ gem sources --remove https://rubygems.org/
https://rubygems.org/ removed from sources


3.安装 taobao 版的
lanou3gdeMac-mini:~ lanou3g$ gem sources -a https://ruby.taobao.org/
https://ruby.taobao.org/ added to sources
//  上面的不可以就试试下面这个吧
gem sources - a http://rubygems-china.oss.aliyuncs.com

4.查找确定是否更新为淘宝版

lanou3gdeMac-mini:~ lanou3g$ gem sources -l
*** CURRENT SOURCES ***

https://ruby.taobao.org/

5.安装  cocoapode
lanou3gdeMac-mini:~ lanou3g$ sudo gem install cocoapods
Password:密码
6.下载第三方
lanou3gdeMac-mini:~ lanou3g$ pod setup
Setting up CocoaPods master repo

7.查询需要的第三方
lanou3gdeMac-mini:~ lanou3g$ pod search AFNetWorking

  1. 执行pod setup
    • 其实在你安装CocoaPods执行pod install时,系统会默认操作pod setup,然而由于中国强大的墙可能会pod setup不成功。这时就需要手动执行pod setup指令,如下:
    • 终端输入:pod setup
    • 会出现Setting up CocoaPods master repo,稍等几十秒,最底下会输出Setup completed。说明执行pod setup成功。
    • 如果pod search操作还是搜索失败,如下:
    • 终端输入:pod search AFNetworking
    • 输出:Unable to find a pod with name, author, summary, or descriptionmatching 'AFNetworking' 这时就需要继续下面的步骤了。
  2. 删除~/Library/Caches/CocoaPods目录下的search_index.json文件
    • pod setup成功后,依然不能pod search,是因为之前你执行pod search生成了search_index.json,此时需要删掉。
    • 终端输入:rm ~/Library/Caches/CocoaPods/search_index.json
    • 删除成功后,再执行pod search
  3. 执行pod search
    • 终端输入:pod search afnetworking(不区分大小写)
    • 输出:Creating search index for spec repo 'master'.. Done!,稍等片刻······就会出现所有带有afnetworking字段的类库。





pod 'AFNetWorking', '~> 3.0'

  1.  将工程文件夹 拖到终端中 cd
lanou3gdeMac-mini:~ lanou3g$ cd /Users/lanou3g/Desktop/UI进阶/Cocopods
lanou3gdeMac-mini:Cocopods lanou3g$ vim Podfile

9.工程中添加第三方
lanou3gdeMac-mini:Cocopods lanou3g$ vim Podfile

10.更新 点 i 进入编辑状态
lanou3gdeMac-mini:Cocopods lanou3g$ vim Podfile
pod 'AFNetworking', '~> 3.0'

按 esc 
输入 :wq

下载类库
lanou3gdeMac-mini:Cocopods lanou3g$ pod update
如果出现[!] No `Podfile' found in the project directory.
返回上一条重新输入 vim Podfile
lanou3gdeMac-mini:Cocopods lanou3g$ vim Podfile

target 'MyApp' do
 pod 'AFNetworking', '~> 3.0'
 end
然后在下载类库 pod update

完成后在工程里面打开带A的,打开程序即可运行
#import 

0 0