iOS CocoaPods Third-party library manager

本篇主要介紹,在iOS開發過程中,
如何使用CocoaPods,第三方套件管理工具。

About CocoaPods

以下是官網上面的介紹,簡單明暸,我就不贅述了。

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.

Get on with building your app, not duplicating code.

Define once, update easily.

Action items

  1. CocoaPods install
  2. How to use CocoaPods

Quick Start

CocoaPods install

Open terminal

1
sudo gem install cocoapods

ps. 安裝過程會花一些時間,請耐心等待

Setup

1
pod setup

How to use CocoaPods

Create Podfile in your project folder.

Edit Podfile

EX: 增加 AFNetworking 套件

1
2
platform :ios
pod 'AFNetworking'

Open terminal - Your project folder path

開始 install AFNetworking 套件

1
pod install

Open Xcode proejct

開啟副檔名為 xcworkspace 的Xcode project
ps. 以後開發此 project ,都是使用 xcworkspace。

增加其他新的套件

  1. Edit Podfile - MBProgressHUD

    1
    pod 'MBProgressHUD'
  2. Update - Open Terminal

    1
    pod update

Reference

文章目录
  1. 1. About CocoaPods
  2. 2. Action items
  3. 3. Quick Start
    1. 3.1. CocoaPods install
      1. 3.1.1. Open terminal
      2. 3.1.2. Setup
    2. 3.2. How to use CocoaPods
      1. 3.2.1. Create Podfile in your project folder.
      2. 3.2.2. Edit Podfile
      3. 3.2.3. Open terminal - Your project folder path
      4. 3.2.4. Open Xcode proejct
      5. 3.2.5. 增加其他新的套件
  4. 4. Reference
,