Note: This is probably out of date since they have made it much more simple to upload pods through their latest CLI.

I was working on a project recently with Xcode using CocoaPods for dependency management. First of all, CocoaPods is (are?) brilliant. However, in all that simplicity I found the documentation relating to how to create one of your own quite scattered. So I thought I'd share my comprehensive example.

For my first pod I created a simple library called Pluralizer. A class that takes a word and number, adds a plural - pretty simple.

Step 1: Create the Xcode Project

There isn't much detail to go into here, it's a standard Xcode project with a couple of unit tests to get the ball rolling. If you are wondering how the algorithm works, you can clone it here:


Step 2: Creating Your Podfile

I assume you already know the basics around using CocoaPods and therefore have the basic tools installed, if you don't see cocoapods.org and I'll see you back here in a bit…

Now, back to where we were. This will create an appropriately named Pluralizer.podspec in the same directory:

cd Pluralizer
pod spec create Pluralizer

When you open this file you will see lots of comments. After going through them (and stripping out all the comments) I was left with just this:

Pod::Spec.new do |s|
s.name = "Pluralizer"
s.version = "1.0"
s.summary = "Simple string pluralization."
s.description = <<-DESC
Simple string pluralization.
DESC
s.homepage = "https://github.com/elliotchance/Pluralizer"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "Elliot Chance" => "elliotchance@gmail.com" }
s.source = { :git => "https://github.com/elliotchance/Pluralizer.git", :tag => "1.0" }
s.source_files = 'Pluralizer/*.{h,m}'
end

The options should be self explanatory, but refer to the comments in your own created podspec for more detail.

Step 3: Submitting Your Pod

If you have used package management before you would probably expect to perhaps create an account through cocoapods.org, then submit your information there. CocoaPods has taken a different approach. The project maintains a huge repository of podspec files here:


Your podspec file should be version controlled with your pod/project. However you will also have to submit your podspec to the above repository.
First thing is to fork the repository and add your podspec file in this format:

podname/version/podname.podspec

In my case this would look like:

Pluralizer/1.0/Pluralizer.podspec

The put in a pull request. I found the response to be very quick (a matter of minutes). However, my pod was not searchable on cocoapods.org stright away, it took over night for it to show up in the main search.

I was able to use the pod immediatly when including it in my Podfile of another project.