• CocoaPods


    一、CocoaPods是什么

    在iOS开发中势必会用到一些第三方依赖库,比如大家都熟悉的ASIHttpRequest、AFNetworking、JSONKit等。使用这些第三方类库能极大的方便项目的开发,但是,集成这些依赖库需要我们手动去配置,例如集成ASIHttpRequest库时除了加入源码以外还需要手动去添加一些系统的framework,CFNetwork、MobileCoreServices等,如果这些第三方库发生了更新,还需要手动去更新项目。这就显得非常麻烦。有麻烦自然有解决办法,CocoaPods就是为了解决这个问题而生的。通过CocoaPods,我们可以将第三方的依赖库统一管理起来,配置和更新只需要通过简单的几行命令即可完成,大大的提高了实际开发中的工作效率,使我们的主要精力集中到更重要的事情上去。

    二、安装CocoaPods

    我的Mac OS X 10.10.5,安装CocoaPods之前,先确保本地有Ruby环境,因为CocoaPods运行于Ruby之上,默认情况下,Mac是自带Ruby环境的,可以通过命令:ruby -v 查看当前Ruby版本,我用的是ruby 2.0.0p481。

    ①安装CocoaPods 命令:$ sudo gem install cocoapods

    上述命令若无效,则需要翻墙,通过镜像来访问CocoaPods,在终端输入如下命令将Ruby镜像替换为淘宝的:

    $ gem sources --remove https://rubygems.org/
    
    $ gem sources -a https://ruby.taobao.org/
    

     完成后可通过如下命令查看当前的Ruby镜像是否已经指向了淘宝:

    $ gem sources -l
    

    输出结果如下:

    *** CURRENT SOURCES ***
    
    https://ruby.taobao.org/
    

     接下来就可以重新执行安装命令,等待安装过程完成即可

    ②验证CocoaPods是否安装成功,输入命令:pod

    结果如下:

     1 caoxinxindeMacBook-Pro:~ caoxinxin$ pod
     2 Usage:
     3 
     4     $ pod COMMAND
     5 
     6       CocoaPods, the Cocoa library package manager.
     7 
     8 Commands:
     9 
    10     + cache      Manipulate the CocoaPods cache
    11     + init       Generate a Podfile for the current directory.
    12     + install    Install project dependencies to Podfile.lock versions
    13     + ipc        Inter-process communication
    14     + lib        Develop pods
    15     + list       List pods
    16     + outdated   Show outdated project dependencies
    17     + plugins    Show available CocoaPods plugins
    18     + repo       Manage spec-repositories
    19     + search     Search for pods.
    20     + setup      Setup the CocoaPods environment
    21     + spec       Manage pod specs
    22     + trunk      Interact with the CocoaPods API (e.g. publishing new specs)
    23     + try        Try a Pod!
    24     + update     Update outdated project dependencies and create new
    25                  Podfile.lock
    26 
    27 Options:
    28 
    29     --silent     Show nothing
    30     --version    Show the version of the tool
    31     --verbose    Show more debugging information
    32     --no-ansi    Show output without ANSI codes
    33     --help       Show help banner of specified command
  • 相关阅读:
    算法
    UVA 10318 Security Panel(DFS剪枝 + 状压 + 思维)题解
    CodeForces 509C Sums of Digits(贪心乱搞)题解
    UVA 10382 Watering Grass(区间覆盖,贪心)题解
    CodeForces 430A Points and Segments (easy)(构造)题解
    CodeForces 459C Pashmak and Buses(构造)题解
    newcoder F石头剪刀布(DFS + 思维)题解
    newcoder H肥猪(单调队列 / 线段树)题解
    UVALive 7501 Business Cycle(二分)题解
    UVALive 7503 Change(乱搞)题解
  • 原文地址:https://www.cnblogs.com/caohexin-Blog/p/4976427.html
Copyright © 2020-2023  润新知