初学者 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。
    三、其他操作

    (1)在终端输入:

pod search json

 

     可以搜索相关json的库,搜索结果显示:
-> AFJSONRPCClient (0.4.0)
   A JSON-RPC client build on AFNetworking.
   pod 'AFJSONRPCClient', '~> 0.4.0'
   - Homepage: https://github.com/AFNetworking/AFJSONRPCClient
   - Source:   https://github.com/AFNetworking/AFJSONRPCClient.git
   - Versions: 0.4.0, 0.3.1, 0.3.0 [master repo]


-> ARSafeJSON (0.0.7)
   ARSafeJSON is a small library that will strip all occurences of NSNull from a
   JSON of any depth.
   pod 'ARSafeJSON', '~> 0.0.7'
   - Homepage: https://bitbucket.org/antoine_r/arsafejson
   - Source:   https://bitbucket.org/antoine_r/arsafejson.git
   - Versions: 0.0.7, 0.0.3 [master repo]


-> AnyJSON (0.1.0)
   Encode / Decode JSON by any means possible.
   pod 'AnyJSON', '~> 0.1.0'
   - Homepage: https://github.com/mattt/AnyJSON
   - Source:   https://github.com/mattt/AnyJSON.git
   - Versions: 0.1.0, 0.0.1 [master repo]
  ............
     
(2)头文件路径 找不到头文件,怎么办?还没设置头文件的目录,在项目的Target的里设置下
          如下图所示,输入${SRCROOT}  后面选上recursive 
初学者 Cocoapods 安装_第1张图片
 
     参考:http://zl4393753.iteye.com/blog/183882
                http://cocoapods.org/ 
                http://shaoke.me/blog/CocoaPods%E7%AE%80%E4%BB%8B/
                http://blog.devtang.com/blog/2012/12/02/use-cocoapod-to-manage-ios-lib-dependency/
                http://blog.csdn.net/totogo2010/article/details/8198694

 

 

你可能感兴趣的:(ios,CocoaPods)