First time I read about CocoaPods, I didn’t think much about it. It said that it’s a the best way to manage Objective-C libraries and the dependencies. Well, I can manage my own library usage myself, no thanks.
Lately I saw many more libraries offer to install via CocoaPods. OK, I’ll give it try, nothing to lose. Let’s install it first.
Installation
The homepage at http://cocoapods.org/ offers simple installation steps. Just open Terminal and hit command:
1 |
[sudo] gem install cocoapods |
When I tried it, nothing happen! It’s just blank, no progress/status message, no nothing. So I have to kill it by “ctrl-c”. I have made sure that I have Ruby which is the prerequisite as CocoaPods will run on top of Ruby. After reading CocoaPods issues on GitHub, I found nothing that fits my case. What I should do is find a way to verbose installation so I know what’s wrong.
Then I tried this command:
1 |
[sudo] gem install -V cocoapods |
Viola! It outputs something. Looking at the verbosed messages, turned out it run well all this time, only took time to complete 🙂
1 2 3 4 5 6 7 8 9 10 |
Andris-MacBook-Pro:/ andri$ sudo gem install -V cocoapods GET http://rubygems.org/latest_specs.4.8.gz 302 Moved Temporarily GET http://production.s3.rubygems.org/latest_specs.4.8.gz 200 OK GET http://rubygems.org/specs.4.8.gz 302 Moved Temporarily GET http://production.s3.rubygems.org/specs.4.8.gz 200 OK .... |
After waiting about 5 minutes, installation was successful! Let’s play around with CocoaPods.
Then when I tried to do “pod setup”, it said:
1 2 |
Andris-MacBook-Pro:/ andri$ pod setup Your RubyGems version (1.8.24) is too old, please update with: `gem update --system` |
OK, let’s update the RubyGems then by hitting command:
1 |
sudo gem update --system |
Don’t forget to use sudo, as it will be failed due to permission issue. Now that the RubyGems was updated, I tried to run “pod setup” again.
1 2 3 4 |
Andris-MacBook-Pro:Social andri$ pod setup Setting up CocoaPods master repo Cloning spec repo `master' from `https://github.com/CocoaPods/Specs.git' (branch `master') Setup completed (read-only access) |
Installing Pod
Now I want to install a Pod here. First I create a Podfile, by hitting command from Terminal:
1 |
edit Podfile |
Then a text editor was opened. I input this text:
1 2 |
platform :ios pod 'DMActivityInstagram', '0.0.1' |
Save the file and issuing this command at Terminal:
1 |
pod install |
Boom! I got error
1 2 3 4 |
Resolving dependencies of `./Podfile' Updating spec repositories Resolving dependencies for target `default' (iOS 4.3) [!] DMActivityInstagram (0.0.1) is not compatible with iOS 4.3. |
Seems my default setting for iOS platform is set to 4.3. Let’s set to iOS 6.0 as required by the Pod I want to install. I edit Podfile again:
1 2 |
platform :ios, '6.0' pod 'DMActivityInstagram', '0.0.1' |
Then hit “pod install” again. The messages:
1 2 3 4 5 6 |
Resolving dependencies of `./Podfile' Updating spec repositories Resolving dependencies for target `default' (iOS 6.0) Downloading dependencies Installing DMActivityInstagram (0.0.1) Generating support files |
1 2 |
[!] From now on use `CollectionViewBlock.xcworkspace'. Integrating `libPods.a' into target `CollectionViewBlock' of Xcode project `./CollectionViewBlock.xcodeproj'. |
And it’s successful! Yay!
*Note: CollectionViewBlock is my Xcode project. You should do all those commands in the working directory of your Xcode project, I guess 🙂