初学者 Cocoapods 安装

  —、 cocapods 安装命令

  (1) 在终端输入:

ruby -v
gem -v
  可以查看ruby的版本号 和 gem的版本号。

  (2) CocoaPods需要ruby环境,所有的mac电脑都已经预装了ruby,所以你需要更新一下

   RubyGems(如果你的系统版本低于OS X Lion)

   只需要输入如下命令就可以更新你的RubyGems:

sudo gem update --system
    安装cocoaPods:
sudo gem install cocoapods
   终端显示:
CHANGELOG:
## 0.26.2
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.26.1...0.26.2)
• [cocoapods-core](https://github.com/CocoaPods/Core/compare/0.26.1...0.26.2)
• [Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.11.1...0.13.0)
###### Bug Fixes
* Fixed a crash which was causing a failure in `pod lib create` if the name of
  the Pod included spaces. As spaces are not supported now this is gracefully
  handled with an informative message.  
  [Kyle Fuller](https://github.com/kylef)
  [#1456](https://github.com/CocoaPods/CocoaPods/issues/1456)
* If an user target doesn't specify an architecture the value specified for the
  project is used in CocoaPods targets.  
  [Fabio Pelosin](https://github.com/irrationalfab)
  [#1450](https://github.com/CocoaPods/CocoaPods/issues/1450
* The Pods project now properly configures ARC on all build configurations.  
  [Fabio Pelosin](https://github.com/irrationalfab)
  [#1454](https://github.com/CocoaPods/CocoaPods/issues/1454)
 
Successfully installed cocoapods-0.26.2
Parsing documentation for cocoapods-0.26.2
Done installing documentation for cocoapods after 6 seconds
1 gem installed

   (3)然后输入:

pod setup

    终端显示:

Setting up CocoaPods master repo
Already up-to-date.
Setup completed (push access)

   二、cocoapod 使用

  (1) 接下来用 cd  命令  进入你要增加 pods 的项目文件夹中 (例:

cd/Desktop/Headlines
    这是进入我桌面的Headlines文件夹) 。

   (2) 现在在你的项目文件中创建Podfile文件

touch Podfile
open -e Podfile

    在Podfile文件中加入如下内容:

platform :ios, '6.0'  
pod 'ViewDeck', '~> 2.2.2'  
pod 'AFNetworking', '~> 1.1.0'  
pod 'SVProgressHUD', '~> 0.9.0'  
pod 'HockeySDK', '~> 3.0.0'

    pod 'AFNetworking' 为项目将依赖的第三方库 保存文件 Podfile  在终端输入命令:

 (3)下载第三方库

pod install
    安装完结束后, 进入你的项目文件夹就可以看到想要的东西啦。要打开工程的话,必须打开XX.xcworkspace 文件,而不是XX.xcodeproj。

相关推荐