cocapods

一、Cocoapods介紹

用來集中管理第三方庫.

作用:導入第三方庫  和  檢測并更新第三方庫

優(yōu)點:無論是ARC的第三方還是MRC的第三方都可以通過cocoapods統(tǒng)一管理,大大提高開發(fā)效率。

二、Cocoapods的安裝

1.更換ruby鏡像地址--速度會加快

刪除鏡像 gem sources --remove https://rubygems.org/

添加淘寶鏡像 gem sources -a https://ruby.taobao.org/

查看當前鏡像 gem sources -l

2.安裝cocoa pods

安裝 sudo gem install cocoa pods

3.驗證安裝是否成功

命令行  pod  出現(xiàn)pod的參數(shù)即可。

三、安裝失敗解決方案

1.卸載重新安裝gem

卸載gem   sudo gem uninstall --all

安裝gem   sudo gem install cocoapods

如果碰到安裝失敗就修改一下安裝路徑,再進行安裝即可。

       mkdir -p $HOME/Software/ruby

       export GEM_HOME=$HOME/Software/ruby

       gem install cocoapods

如果碰到安裝失敗,也可以這樣操作(指定安裝目錄)

       sudo gem install -n /usr/local/bin cocoapods

2.更新gem

更新gem   sudo gem update --system

四、cocoa pods命令

4.1為項目初始化pod

pod init

4.2為項目安裝pod

pod install  直接從網(wǎng)絡下載
pod install --no-repo-update 先從本地加載,沒有就在網(wǎng)絡加載(速度快)

4.3更新第三方庫 和 新添加第三方庫

pod update

4.4搜索第三方插件

pod search xxx 

4.5查看本地存在的第三方庫

pod cache list

五、iOS項目配置cocoa pods

1.命令行進入到項目文件夾中
2.執(zhí)行pod init 會生成 Podfile 文件
3.xcode 打開 Podfile 文件
4.配置自己想要的第三方類庫即可
5.配置完成后執(zhí)行 pod install 進行安裝
6.項目中多了.xcworkspace文件,打開這個文件即可。
7.添加新的第三方或者更新第三方,修改Podfile文件,執(zhí)行pod update。

六、配置第三方庫

第三方庫逗號后邊是版本,不寫默認當前最高版本
platform :ios, '8.0'
pod 'AFNetworking','~> 2.6.1'
pod 'SDWebImage', '~> 3.7.3'
pod 'MMDrawerController'

7.pod 命令

7.1pod幫助指令

?  ~ pod --help
Usage:

    $ pod COMMAND

      CocoaPods, the Cocoa library package manager.

Commands:  pod的所有子命令

    + cache      Manipulate the CocoaPods cache
    + init       Generate a Podfile for the current directory.
    + install    Install project dependencies to Podfile.lock versions
    + ipc        Inter-process communication
    + lib        Develop pods
    + list       List pods
    + outdated   Show outdated project dependencies
    + plugins    Show available CocoaPods plugins
    + repo       Manage spec-repositories
    + search     Search for pods.
    + setup      Setup the CocoaPods environment
    + spec       Manage pod specs
    + trunk      Interact with the CocoaPods API (e.g. publishing new specs)
    + try        Try a Pod!
    + update     Update outdated project dependencies and create new
                 Podfile.lock

Options: 選項

    --silent     Show nothing
    --version    Show the version of the tool
    --verbose    Show more debugging information
    --no-ansi    Show output without ANSI codes
    --help       Show help banner of specified command

7.2pod子命令的幫助指令

?  ~ pod update --help
Usage:

    $ pod update [POD_NAMES ...]

      Updates the Pods identified by the specified `POD_NAMES`. If no
      `POD_NAMES` are specified it updates all the Pods ignoring the contents of
      the Podfile.lock. This command is reserved to the update of dependencies
      and pod install should be used to install changes to the Podfile.

Options: 選項

    --project-directory=/project/dir/   The path to the root of the project
                                        directory
    --no-clean                          Leave SCM dirs like `.git` and `.svn`
                                        intact after downloading
    --no-integrate                      Skip integration of the Pods libraries
                                        in the Xcode project(s)
    --no-repo-update                    Skip running `pod repo update` before
                                        install
    --silent                            Show nothing
    --verbose                           Show more debugging information
    --no-ansi                           Show output without ANSI codes
    --help                              Show help banner of specified command

8.pod-Xcode使用

1.下載
1.1github 下載地址:
  https://github.com/CocoaPods/Xcodeproj
1.2Alcatraz 中搜索 Cocoapods
1.3安裝插件

8.1為項目初始化pod



8.2填寫第三方庫



8.3為項目安裝pod

8.4安裝完成通過pod打開項目



8.5修改pod增刪第三方庫

8.6更新pod庫
最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • CocoaPods 是什么? CocoaPods 是一個負責管理 iOS 項目中第三方開源庫的工具。CocoaPo...
    朝洋閱讀 25,990評論 3 50
  • 項目組件化、平臺化是技術公司的共同目標,越來越多的技術公司推崇使用pod管理第三方庫以及私有組件,一方面使項目架構...
    swu_luo閱讀 22,845評論 0 39
  • 一. CocoaPods的介紹 什么是CocoaPods?CocoaPods是一個負責管理iOS項目中第三方開源庫...
    輝712閱讀 4,109評論 0 7
  • 即將到來的30歲。 慢慢的會遇到一些從未經(jīng)歷過的事,要硬著頭皮和臉皮去做。過程偶有不順,也并不會覺得...
    芯寧大人閱讀 253評論 0 0
  • 今天我有一百個理由想見你,卻沒有一個見你的身份。 你是我關上燈,才能擁有的夢。 明明我們認識更早,你說你們認識剛好...
    兮鈴閱讀 508評論 0 0

友情鏈接更多精彩內(nèi)容