ref – http://stackoverflow.com/questions/23755974/cocoapods-pod-install-takes-forever
https://www.raywenderlich.com/156971/cocoapods-tutorial-swift-getting-started
Install cocoapods
First, install pod:
1 |
sudo gem install cocoapods |
The verbose option logs progress as the process runs, allowing you to watch the process instead of seeing a seemingly “frozen” screen.
1 |
pod setup --verbose |
Note: If you have previously installed pod and want to do a re-install do this:
1 2 3 |
pod repo remove master pod setup --verbose (2 dashes) pod install --verbose (2 dashes) |
Create a xCode project
Open Terminal and navigate to the directory that contains your project by using the cd command:
cd ~/Path/To/Folder/YourProject
Next, enter the following command:
1 |
pod init |
Go into the root directory of the project.
This creates a Podfile for your project.
Finally, type the following command to open the Podfile using Xcode for editing:
1 |
open -a Xcode Podfile |
Note: You shouldn’t use TextEdit to edit the Podfile because it replaces standard quotes with more graphically appealing typeset quotes. This can cause CocoaPods to become confused and throw errors, so it’s best to use Xcode or another programming text editor to edit your Podfile.
The default Podfile looks like this:
1 2 3 4 5 6 7 8 9 10 |
# Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'ProjectName' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! # Pods for ProjectName end |
Delete the # and space before platform, and delete the other lines starting with #.
Your Podfile should now look like this:
1 2 3 4 5 6 |
platform :ios, '9.0' target 'ProjectName' do use_frameworks! end |
This tells CocoaPods your project is targeting iOS 9.0 and will be using frameworks instead of static libraries.
In order to use CocoaPods written in Swift, you must explicitly include use_frameworks! to opt into using frameworks. If you forget to include this, and CocoaPods detects you’re trying to use a Swift CocoaPod, you’ll get an error when you try to install the pods.
Installing your Dependency
It’s finally time to add your first dependency using CocoaPods. Add the following to your Podfile, right after use_frameworks!:
1 |
pod 'Alamofire', '4.4.0' |
This tells CocoaPods you want to include Alamofire version 4.4.0 – the latest, stable version at the time of writing this tutorial – as a dependency for your project.
Save and close the Podfile.
You now need to tell CocoaPods to install the dependencies for your project. Enter the following command in Terminal, after ensuring you’re still in the directory containing your project and Podfile:
1 |
pod install |
You should see output similar to the following:
Analyzing dependencies
Downloading dependencies
Installing Alamofire (4.4.0)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use YourProject.xcworkspace
for this project from now on.
Open the project folder using Finder, and you’ll see CocoaPods created a new YourProject.xcworkspace file and a Pods folder in which to store all the project’s dependencies.