How to import library using cocoa pods

CocoaPods URL

http://cocoapods.org

Using CocoaPods is really easy to import Library to our iOS project.

I will show you how to import a library. I use MarqueeLabel as an example.

MarqueeLabel GitHub

https://github.com/cbpowell/MarqueeLabel

First we need instal Ruby.
I use third-party-tool to install it.

Ruby Version Manager (RVM)

http://rvm.io

Type the following code in Terminal :

\curl -sSL https://get.rvm.io | bash -s stable

After installing Ruby, we need to install CocoaPods now.

sudo gem install cocoapods

If you can't get anything now, maybe your Internet is blocked. I use these to change the install source.

gem sources --remove https://rubygems.org/
gem sources -a http://ruby.taobao.org/

Type this to check

gem sources -l

It will then display :

*** CURRENT SOURCES ***
http://ruby.taobao.org/

Run install code again

sudo gem install cocoapods

After the installation completed, use cd command to direct to your project folder. Then, we create a Podfile using vim command

vim Podfile

Type the following

platform :ios, '7.1'
pod 'MarqueeLabel', '~> 1.4.1'

press Exit, and type   :wq    to exit editing with saving

Then install it now

pod install

Now you can open your Xcode (xworkspace)

open YourAppName.xcworkspace

Try to import it in your file

#import "MarqueeLabel.h"

Succeed ?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s