本篇主要介紹,在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
- CocoaPods install
 - 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  | platform :ios  | 
Open terminal - Your project folder path
開始 install AFNetworking 套件
1  | pod install  | 
Open Xcode proejct
開啟副檔名為 xcworkspace 的Xcode project
ps. 以後開發此 project ,都是使用 xcworkspace。
增加其他新的套件
Edit Podfile - MBProgressHUD
1
pod 'MBProgressHUD'
Update - Open Terminal
1
pod update