iOS技术分享

cocoapods的安装

2016-09-02  本文已影响157人  上善若水jf

    大多数iOS库都支持CocoaPods,用CocoaPods可以非常方便快捷的将效果库加入到项目中。

如果你是一名iOS开发者,那么肯定会遇到需要使用CocoaPods的场景。所以,我们来学习一下CocoaPods,看看它是怎样方便你进行项目管理的。

CocoaPods是什么:

CocoaPods是Objective-C项目的从属管理器,是库管理工具,能方便引入上千个开源库,让你的项目更加灵活。

CocoaPods官网:http://cocoapods.org/

cocoapods安装步骤

1、检查ruby 版本:ruby -v

2、如果ruby不是最新版本,将ruby更新到最新版本:gem update --system

3、验证你的Ruby镜像是并且仅是taobao,可以用以下命令查看:gem sources -l

只有在终端中出现下面文字才表明你上面的命令是成功的:

*** CURRENT SOURCES ***

https://ruby.taobao.org/

4、可能存在错误路径是:

解决办法:

4.1、移除错误路径:gem sources —remove  http://ruby.taobao.org

4.2、移除错误路径:gem sources —remove  http://ruby.taobao.org/

插入正确镜像路径:gem sources -ahttps://ruby.taobao.org/

5、执行安装cocoapods命令:sudo gem install cocoapods

安装正确时,会输出很多文件以及进度条,如下:

Fetching: nap-1.1.0.gem (100%)

Successfully installed nap-1.1.0

Fetching: cocoapods-core-1.0.1.gem (100%)

Successfully installed cocoapods-core-1.0.1

Fetching: claide-1.0.0.gem (100%)

Successfully installed claide-1.0.0

Fetching: cocoapods-deintegrate-1.0.0.gem (100%)

Successfully installed cocoapods-deintegrate-1.0.0

Fetching: cocoapods-downloader-1.1.0.gem (100%)

Successfully installed cocoapods-downloader-1.1.0

Fetching: cocoapods-plugins-1.0.0.gem (100%)

Successfully installed cocoapods-plugins-1.0.0

Fetching: cocoapods-search-1.0.0.gem (100%)

Successfully installed cocoapods-search-1.0.0

Fetching: cocoapods-stats-1.0.0.gem (100%)

Successfully installed cocoapods-stats-1.0.0

Fetching: cocoapods-trunk-1.0.0.gem (100%)

Successfully installed cocoapods-trunk-1.0.0

Fetching: cocoapods-try-1.1.0.gem (100%)

Successfully installed cocoapods-try-1.1.0

Fetching: molinillo-0.4.5.gem (100%)

Successfully installed molinillo-0.4.5

Fetching: xcodeproj-1.2.0.gem (100%)

Successfully installed xcodeproj-1.2.0

Fetching: fourflusher-0.3.2.gem (100%)

Successfully installed fourflusher-0.3.2

Fetching: cocoapods-1.0.1.gem (100%)

Successfully installed cocoapods-1.0.1

Fetching: concurrent-ruby-1.0.2.gem (100%)

Successfully installed concurrent-ruby-1.0.2

Parsing documentation for nap-1.1.0

Installing ri documentation for nap-1.1.0

Parsing documentation for cocoapods-core-1.0.1

Installing ri documentation for cocoapods-core-1.0.1

Parsing documentation for claide-1.0.0

Installing ri documentation for claide-1.0.0

Parsing documentation for cocoapods-deintegrate-1.0.0

Installing ri documentation for cocoapods-deintegrate-1.0.0

Parsing documentation for cocoapods-downloader-1.1.0

Installing ri documentation for cocoapods-downloader-1.1.0

Parsing documentation for cocoapods-plugins-1.0.0

Installing ri documentation for cocoapods-plugins-1.0.0

Parsing documentation for cocoapods-search-1.0.0

Installing ri documentation for cocoapods-search-1.0.0

Parsing documentation for cocoapods-stats-1.0.0

Installing ri documentation for cocoapods-stats-1.0.0

Parsing documentation for cocoapods-trunk-1.0.0

Installing ri documentation for cocoapods-trunk-1.0.0

Parsing documentation for cocoapods-try-1.1.0

Installing ri documentation for cocoapods-try-1.1.0

Parsing documentation for molinillo-0.4.5

Installing ri documentation for molinillo-0.4.5

Parsing documentation for xcodeproj-1.2.0

Installing ri documentation for xcodeproj-1.2.0

Parsing documentation for fourflusher-0.3.2

Installing ri documentation for fourflusher-0.3.2

Parsing documentation for cocoapods-1.0.1

Installing ri documentation for cocoapods-1.0.1

Parsing documentation for concurrent-ruby-1.0.2

Installing ri documentation for concurrent-ruby-1.0.2

15 gems installed

6、cocoapods安装的默认文件路径:~/.cocoapods

7、检查cocoapods是否安装正确:在终端输入pod search AFNetworking

如果cocoa pods安装正确,则会出现以下显示:

AFNetworking (3.1.0)

A delightful iOS and OS X networking framework.

pod 'AFNetworking', '~> 3.1.0'

- Homepage: https://github.com/AFNetworking/AFNetworking

- Source:  https://github.com/AFNetworking/AFNetworking.git

- Versions: 3.1.0, 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0.0, 3.0.0-beta.3,

3.0.0-beta.2, 3.0.0-beta.1, 2.6.3, 2.6.2, 2.6.1, 2.6.0, 2.5.4, 2.5.3, 2.5.2,

2.5.1, 2.5.0, 2.4.1, 2.4.0, 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]

- Subspecs:

- AFNetworking/Serialization (3.1.0)

- AFNetworking/Security (3.1.0)

- AFNetworking/Reachability (3.1.0)

- AFNetworking/NSURLSession (3.1.0)

- AFNetworking/UIKit (3.1.0)

上一篇下一篇

猜你喜欢

热点阅读