Reference text: http://www.cocoachina.com/swift/20150630/12305.html
1, first you need to install Cocoapods. Fortunately, Cocoapods is built on Ruby, and the latest version of Mac OS X comes with Ruby. This has been done since OS X 10.7.
Open the terminal and enter the following command line:
sudo gem install Cocoapods
Enter the following command line at the terminal to complete the setup:
Pod Setup--verbose2, turn off the program,Open the terminal and use the CD command to enter the directory containing your Icecreamshop project:CD (drag folder)3. Create a Podfile for your project:pod init4.to edit podfile using Xcode:Open-a Xcode PodfileNote:You cannot use TextEdit to edit podfile, as it is possible to replace standard quotes with a more attractive graphical typeset quotes, which may cause cocoapods to fail to understand and throw an error, So it's best to use Xcode or another programming text editor to edit your podfile. 5. The default podfile looks like this:
# Uncomment this line to define a global platform for your project
# platform :ios, ‘6.0‘
target
‘IceCreamShop‘
do
end
target
‘IceCreamShopTests‘
do
end
Replace the contents of the comment with the following two lines:
platform :ios,
"8.0"
use_frameworks!
This tells cocoapods--that your project is using iOS 8.0 and that the framework will be used instead of the static library. To download the HUD library:
pod
‘MBProgressHUD‘
,
‘~> 0.9.0‘
To get:
Platform:ios, "8.0"
use_frameworks!
Target ' Myswift ' do
Pod ' Mbprogresshud ', ' ~> 0.9.0 '
End
Target ' myswifttests ' do
End
6. Download the library file (very slow for the first time)
Pod Install
7. Open Project with workspace file
Using Cocoapods in Swift