CocoaPods 安装和使用
来源:互联网 发布:财政部会计报表软件 编辑:程序博客网 时间:2024/06/05 10:59
CocoaPods是什么?
1.说这么一个现场,如果要引用第三方类库是不是要把他拖进项目引用或者copy,如果第三方类库更新了,你是不是又要重新应用更新啊?答案是肯定的。
2.另外一种情况,如果项目过大,且项目中有很多相对独立的功能,分工到不同人的手中维护升级开发,最后整合项目(其实可把他们看作第三方类库),是不是也会遇到copy或者引用的问题。
以上两点会导致,遇到更改就要换代码换文件,如果你的项目就一个,可以很轻松换掉,如果是10个 ,100个....估计就该抱怨了,cocoapos一个链接就搞定了,可以很好提高效率,同时有利于分工协作。
今天把cocoapods安装过程总结分享给大家。
CocoaPods安装
第一步:安装CocoaPods之前,首先要在本地安装好Ruby环境。(ruby安装 https://ruby-china.org/wiki/install_ruby_guide)
安装ruby过程如下:
a.确保 已经安装xCode的Command Line Tools
b.打开终端:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew install ruby
第二步: 当b步骤执行成功后,在终端输入:
sudo gem install cocoapods发现没有反映,别急换个方法:
如果发现报:Could not find a valid gem 'cocoapods' (>= 0) in any repository 别急,这个问题说明是你的gem版本过旧了 (没有报错此步骤可以跳过)
在终端先输入:
sudo gem update --system
重新打开终端输入:
gem sources --remove https://rubygems.org/会返回:
https://rubygems.org/ removed from sources
在输入:gem sources -a https://ruby.taobao.org/会返回:
https://ruby.taobao.org/ added to sources
检测一下在终端输入:gem sources -l得到如下:
*** CURRENT SOURCES ***
https://ruby.taobao.org/
为什么这么做?原因是国家的防火墙有点牛,猜的!第三步:再次输入:
sudo gem install cocoapods
等待几十秒会返回:
Fetching: multi_json-1.10.1.gem (100%)Successfully installed multi_json-1.10.1Fetching: activesupport-3.2.19.gem (100%)Successfully installed activesupport-3.2.19Fetching: nap-0.8.0.gem (100%)Successfully installed nap-0.8.0Fetching: json_pure-1.8.1.gem (100%)Successfully installed json_pure-1.8.1Fetching: fuzzy_match-2.0.4.gem (100%)Successfully installed fuzzy_match-2.0.4Fetching: cocoapods-core-0.33.1.gem (100%)Successfully installed cocoapods-core-0.33.1Fetching: claide-0.6.1.gem (100%)Successfully installed claide-0.6.1Fetching: colored-1.2.gem (100%)Successfully installed colored-1.2Fetching: xcodeproj-0.17.0.gem (100%)Building native extensions. This could take a while...[!] You are using the prebuilt binary version of the xcodeproj gem.Successfully installed xcodeproj-0.17.0Fetching: cocoapods-downloader-0.6.1.gem (100%)Successfully installed cocoapods-downloader-0.6.1Fetching: cocoapods-plugins-0.2.0.gem (100%)Successfully installed cocoapods-plugins-0.2.0Fetching: cocoapods-try-0.3.0.gem (100%)Successfully installed cocoapods-try-0.3.0Fetching: netrc-0.7.7.gem (100%)Successfully installed netrc-0.7.7Fetching: cocoapods-trunk-0.1.4.gem (100%)Successfully installed cocoapods-trunk-0.1.4Fetching: escape-0.0.4.gem (100%)Successfully installed escape-0.0.4Fetching: open4-1.3.4.gem (100%)Successfully installed open4-1.3.4Fetching: cocoapods-0.33.1.gem (100%)CHANGELOG:## 0.33.1##### Bug Fixes* Fix `pod spec lint` for `json` podspecs. [Fabio Pelosin][irrationalfab] [#2157](https://github.com/CocoaPods/CocoaPods/issues/2157)* Fixed downloader issues related to `json` podspecs. [Fabio Pelosin][irrationalfab] [#2158](https://github.com/CocoaPods/CocoaPods/issues/2158)* Fixed `--no-ansi` flag in help banners. [Fabio Pelosin][irrationalfab] [#34](https://github.com/CocoaPods/CLAide/issues/34)Successfully installed cocoapods-0.33.1Parsing documentation for multi_json-1.10.1Installing ri documentation for multi_json-1.10.1Parsing documentation for activesupport-3.2.19unable to convert "\x80" from ASCII-8BIT to UTF-8 for lib/active_support/values/unicode_tables.dat, skippingInstalling ri documentation for activesupport-3.2.19Parsing documentation for nap-0.8.0Installing ri documentation for nap-0.8.0Parsing documentation for json_pure-1.8.1Installing ri documentation for json_pure-1.8.1Parsing documentation for fuzzy_match-2.0.4Installing ri documentation for fuzzy_match-2.0.4Parsing documentation for cocoapods-core-0.33.1Installing ri documentation for cocoapods-core-0.33.1Parsing documentation for claide-0.6.1Installing ri documentation for claide-0.6.1Parsing documentation for colored-1.2Installing ri documentation for colored-1.2Parsing documentation for xcodeproj-0.17.0Installing ri documentation for xcodeproj-0.17.0Parsing documentation for cocoapods-downloader-0.6.1Installing ri documentation for cocoapods-downloader-0.6.1Parsing documentation for cocoapods-plugins-0.2.0Installing ri documentation for cocoapods-plugins-0.2.0Parsing documentation for cocoapods-try-0.3.0Installing ri documentation for cocoapods-try-0.3.0Parsing documentation for netrc-0.7.7Installing ri documentation for netrc-0.7.7Parsing documentation for cocoapods-trunk-0.1.4Installing ri documentation for cocoapods-trunk-0.1.4Parsing documentation for escape-0.0.4Installing ri documentation for escape-0.0.4Parsing documentation for open4-1.3.4Installing ri documentation for open4-1.3.4Parsing documentation for cocoapods-0.33.1Installing ri documentation for cocoapods-0.33.117 gems installed
我的终端:
CocoaPods使用
使用很简单如在终端输入:
pod search AFNetworking结果返回:
Setting up CocoaPods master repo
嚓,知道吗?我等了足足半个小时。所以请内心等待.半小时之后返回:
Setup completed (read-only access)
-> AFNetworking (2.3.1)
A delightful iOS and OS X networking framework.
pod 'AFNetworking', '~> 2.3.1'
- Homepage: https://github.com/AFNetworking/AFNetworking
- Source: https://github.com/AFNetworking/AFNetworking.git
- Versions: 2.3.1, 2.3.0, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.0, 2.0.3, 2.0.2, 2.0.1,
2.0.0, 2.0.0-RC3, 2.0.0-RC2, 2.0.0-RC1, 1.3.4, 1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.1, 1.2.0,
1.1.0, 1.0.1, 1.0, 1.0RC3, 1.0RC2, 1.0RC1, 0.10.1, 0.10.0, 0.9.2, 0.9.1, 0.9.0, 0.7.0,
0.5.1 [master repo]
- Sub specs:
- AFNetworking/Serialization (2.3.1)
- AFNetworking/Security (2.3.1)
- AFNetworking/Reachability (2.3.1)
- AFNetworking/NSURLConnection (2.3.1)
- AFNetworking/NSURLSession (2.3.1)
- AFNetworking/UIKit (2.3.1)
-> AFNetworking+AutoRetry (0.0.3)
Auto Retries for AFNetworking requests
pod 'AFNetworking+AutoRetry', '~> 0.0.3'
- Homepage: https://github.com/shaioz/AFNetworking-AutoRetry
- Source: https://github.com/shaioz/AFNetworking-AutoRetry.git
- Versions: 0.0.3, 0.0.2, 0.0.1 [master repo]
-> AFNetworking+streaming (0.5)
A very quick extension to AFNetworking that adds stream based parsing
pod 'AFNetworking+streaming', '~> 0.5'
- Homepage: https://github.com/deanWombourne/AFNetworking-streaming
- Source: https://github.com/deanWombourne/AFNetworking-streaming.git
- Versions: 0.5, 0.4, 0.3, 0.2, 0.1 [master repo]
- Sub specs:
- AFNetworking+streaming/Core (0.5)
- AFNetworking+streaming/Json (0.5)
-> AFNetworking-MUResponseSerializer (1.0.0)
Automatically serialize JSON response to your object model. It also works with
NSManagedObjects.
pod 'AFNetworking-MUResponseSerializer', '~> 1.0.0'
- Homepage: https://github.com/Ulianko/AFNetworking-MUResponseSerializer
- Source: https://github.com/Ulianko/AFNetworking-MUResponseSerializer.git
- Versions: 1.0.0 [master repo]
-> AFNetworking-RACExtensions (0.1.4)
AFNetworking-RACExtensions is a delightful extension to the AFNetworking classes for iOS
and Mac OS X.
pod 'AFNetworking-RACExtensions', '~> 0.1.4'
- Homepage: https://github.com/CodaFi/AFNetworking-RACExtensions
- Source: https://github.com/CodaFi/AFNetworking-RACExtensions.git
- Versions: 0.1.4, 0.1.2, 0.1.1, 0.0.1 [master repo]
-> AFNetworking-ReactiveCocoa (0.0.2)
Make AFNetworking reactive.
pod 'AFNetworking-ReactiveCocoa', '~> 0.0.2'
- Homepage: https://github.com/uasi/AFNetworking-ReactiveCocoa
- Source: https://github.com/uasi/AFNetworking-ReactiveCocoa.git
- Versions: 0.0.2, 0.0.1 [master repo]
-> AFNetworking-Synchronous (0.2.0)
Synchronous requests for AFNetworking
pod 'AFNetworking-Synchronous', '~> 0.2.0'
- Homepage: https://github.com/paulmelnikow/AFNetworking-Synchronous
- Source: https://github.com/paulmelnikow/AFNetworking-Synchronous.git
- Versions: 0.2.0, 0.1.0 [master repo]
-> AFNetworking2-RACExtensions (0.0.1)
AFNetworking-RACExtensions is a delightful extension to the AFNetworking classes for iOS
and Mac OS X.
pod 'AFNetworking2-RACExtensions', '~> 0.0.1'
- Homepage: https://github.com/knshiro/AFNetworking-RACExtensions
- Source: https://github.com/knshiro/AFNetworking-RACExtensions.git
- Versions: 0.0.1 [master repo]
-> CollectionUtils-AFNetworking (1.0.1)
CollectionUtils additions for AFNetworking.
pod 'CollectionUtils-AFNetworking', '~> 1.0.1'
- Homepage: https://github.com/kishikawakatsumi/CollectionUtils
- Source: https://github.com/kishikawakatsumi/CollectionUtils.git
- Versions: 1.0.1, 1.0.0 [master repo]
-> CollectionUtils-AFNetworking-1.3 (1.0.1)
CollectionUtils additions for AFNetworking 1.3.x.
pod 'CollectionUtils-AFNetworking-1.3', '~> 1.0.1'
- Homepage: https://github.com/kishikawakatsumi/CollectionUtils
- Source: https://github.com/kishikawakatsumi/CollectionUtils.git
- Versions: 1.0.1, 1.0.0 [master repo]
- 安装cocoaPods和使用cocoapods
- CocoaPods安装和使用
- 安装和使用cocoaPods
- CocoaPods安装和使用
- Cocoapods安装和使用
- 安装和使用CocoaPods
- CocoaPods安装和使用
- CocoaPods 安装和使用
- CocoaPods安装和使用
- CocoaPods安装和使用
- CocoaPods安装和使用
- cocoapods 安装和使用
- CocoaPods安装和使用
- CocoaPods安装和使用
- CocoaPods安装和使用
- 安装CocoaPods和使用
- CocoaPods安装和使用
- CocoaPods安装和使用
- 《从零开始学Swift》学习笔记(Day 8)——小小常量、变量大作用
- SpringMVC配置字符串绑定日期对象
- setOnItemSelectedListener与OnItemClickListener的区别
- uboot 命令构造宏分析
- STL源码剖析 [容器](十四)[stl_set.h]
- CocoaPods 安装和使用
- ArcGIS for Android示例解析之空间查询-----QueryTask
- Android中AsyncTask类与AsyncQueryHandler类的用法
- 子网划分两个例子---经典
- 数组存储在栈中还是堆中
- 通过Intent传递一些二进制数据的方法有哪些?
- 黑马程序员——36,Collections工具类,Arrays工具类,高级for循环,可变参数,静态导入
- hdu 2844 Coins (多重背包)
- Java中用System.getProperty("...")获取系统属性