cocoapods安装与使用

来源:互联网 发布:郭德纲人品 知乎 编辑:程序博客网 时间:2024/05/20 23:05

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.打开终端:

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
第二步: 当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 http://ruby.taobao.org/
            会返回:

            http://ruby.taobao.org/ added to sources

            检测一下在终端输入:
gem sources -l
            得到如下:

            *** CURRENT SOURCES ***

            http://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]




0 0
原创粉丝点击