If youre already reading this you probably know what cocoapods are and why they are essential for iOS development.. so lets get to it.

more: http://guides.cocoapods.org/making/making-a-cocoapod.html

Installing / Updating

$ sudo gem install cocoapods will prompt for your computers password be patient…

if updating you might have to run $ pod repo remove master // fixes an error of fast-forward

$ pod setup

Adding pods to my projects

cd to your projects folder (where .xcodeproj is located)

$ pod init // will create a podfile ( http://guides.cocoapods.org/using/the-podfile.html

open the podfile in your editor and add the libraries you desire platform :ios, '7.0'

pod 'AFNetworking', '~> 2.2' // for AFNetworking version 2.2 pod 'ABC', :git => 'https://github.com/HelloMihai/ABC.git', :commit => 'b2g4y5fe4' // add a library thats not public for a specific commit pod ' HMDevKitObjc /Core/CoreA' // add a specific Subspec and not the entire library

close Xcode if open before installing libraries

$ pod install // install the libraries added to this project

open <ProjectName>.xcworkspace // if you open the .xcodeproj your libraries wont be seen

import a file with <name.h> not “name.h” #import <HMBasicAnimation.h>

Updating project libraries

cd to your projects folder (where .xcodeproj is located)

$ pod update

Creating your own pods

create a single gitHub repository for all your libraries to link to one cocoaPod // eg: https://github.com/HelloMihai/HMDevKitObjc

create two folders Classes // add your subfolders with classes there eg: Classes/HMExample/HMExample.h and .m Exclude // excluded from being pulled

add the LICENCE file of your choice

$ pod spec create HMDevKitObjc | https://github.com/HelloMihai/HMDevKitObjc.git // creates a base podspec file

edit the podspec file with your desired email, name etc and note the tag “0.0.1”

$ git init // init your git repository

$ git add -A // add all files

$ git commit -m "initial commit" // commit files

$ git remote add origin http://github.com/HelloMihai/HMDevKitObjc.git // link to remote repo

$ git push -u origin master // push changes to server

$ git tag 0.0.1 // tag the current repository

$ git push --tags // push tags to the server

$ pod spec lint HMDevKitObjc.podspec // run to ensure this is a valid spec and to remove all comments including this before submitting the spec. Should have no errors

$ pod lib lint // test syntax of pod file. Should have no errors

end result for the file should be something similar to this Pod::Spec.new do |s| s.name = "HMDevKitObjc" s.version = "0.0.1" s.summary = "ObjectiveC libraries for ios development" s.homepage = "http://HelloMihai.wordpress.com" s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = "HelloMihai" s.platform = :ios, "7.0" s.source = { :git => "https://github.com/HelloMihai/HMDevKitObjc.git", :tag => "0.0.1" } s.source_files = "Classes", "Classes/**/*.{h,m}" s.exclude_files = "Classes/Exclude" s.requires_arc = true end

push your changes again to the server

test your new pod create a new project and init cocoapods for it $ pod init // initialize cocoapods edit the podfile for the test project platform :ios, "7.0" pod 'HMDevKitObjc', :git => 'https://github.com/HelloMihai/HMDevKitObjc.git' close Xcode if open before installing libraries $ pod install // install the new pod open the .xcwordspace project and you should now see the following pod files

import a file with <name.h> not “name.h” #import <HMBasicAnimation.h>



Pushing to Public

make sure you have the latest version of CocoaPods (see install/update section above)

$ pod trunk register YourName@Email.com 'Your Name' --description='computer description'

wait for email and click the link

$ pod trunk me // see your current session

$ pod trunk push // finally push your trunk to cocoapods for public access

Users then can add your cocoaPod by adding to their projects podfile

pod 'HMDevKitObjc'