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. :)
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.