Click here to Skip to main content
Click here to Skip to main content

Using CocoaPods on iOS

, 4 Mar 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
Configuring and using CocoaPods on iOS projects.

Introduction

CocoaPods is the dependency manager for Objective-C projects. It has thousands of libraries and can help you scale your projects elegantly. I want to show you how to use in your project.

Background

Check this out and install CocoaPods on your mac : http://cocoapods.org.

Simply:

sudo gem install cocoapods 
pod setup 

Using the Code

First, I created an empty application and added one ViewController with xib. Then, I added a button into View.

After that, you should open Terminal windows on project folder. You have to create Podfile for using pods.

Run this command for creating Podfile of your project:

 pico 

I want to use TSMessage library for showing little notification views on the top of the screen.

In pico editor, you should write like this:

platform :ios, '7.0'
pod 'TSMessages'  

Press the Control-O and enter name 'Podfile' then hit the enter button for saving pod file. Press Control-X for closing pico editor.

Now, check your project folder and see your Podfile.

Are you ready to install pod? Go on. Run this command on Terminal:

pod install 

This process may take some time, be patient. At the end, you should get result like this:

Go and check your project folder again.

As you see, Pod files and workspace have been created. Close Xcode and run again using .xcworkspace file.

Now you have your project and TSMessage library. Let's use it. Smile | :)

You should import TSMessage library into ViewController.

Simply:

#import "TSMessage.h"

At the beginning of this tutorial, I said, I added one button into the View.

I want to show notification when user clicks the this button.

- (IBAction)sampleButtonClick:(id)sender { 

[TSMessage showNotificationWithTitle:@"Bildirim basligi" 

subtitle:@"Çok fena bir hata aldiniz !!" 

type:TSMessageNotificationTypeError];

} 

That's it !

Points of Interest

Check the CocoaControls for interesting libraries for iOS.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Melih Mucuk
Software Developer NoMad Commerce
Turkey Turkey
Melih Mucuk
 
Software & Mobile App Developer
 
Visit my blog: http://melihmucuk.com
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 4 Mar 2014
Article Copyright 2014 by Melih Mucuk
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid