How I created my very first CocoaPods?

From now, you can integrate Printer using CocoaPods as well. After juggling for almost 10 days – I was able to create my very first Pod.

pod 'printer-logger', '~>1.0'

In this article I will not write about how I did that successfully whether I will add the problems I’d faced during this period.

If you want to do the same, you can read out the well written steps in this repo. However, I was needed to search here and there and do different experiments to make it a working pod. There are certainly few people who is also responsible that I have written this post. You can read more about this here.

First of all, why the Pod name is a “printer-logger” and not a “printer”? Yes, this should be the first question. The reason is that, the name “printer” is already occupied at the time of creating the pod for Printer. So we should provide a unique name to our pod thus it I have choose the name: “printer-logger” as the core function of the Printer is to logging events for an application.

Why I have spent these much of days for a normal task? This is not the whole time I was spending on this thing. However, when I was free a little from my work I tried many things to get this thing done. But it has many problem until it finally worked for me.

If you are also going to create your first Pod, here is my quite few advices before you take a step:

  1. Always give a valid prefix to your classes. For example: My first name starts with “H” and last name starts with “S”. My prefix can be “HS”. Why this require? This will not make any confusion when choosing a Pod name. Like the problem I faced for the Printer. 
  2. Always add proper access specifiers for each of your classes, functions, variables and everything which a user will be accessing as a part of functionality in his work.
  3. Understanding of private, fileprivate, public access specifiers. This is very important when you want to make your CocoaPods.
  4. As soon as you planned to create a repository make sure to create a Pod entry for the same. This will allow you in advance to have the same named CocoaPods for your repo.

If you need any help with this – please feel free to add a comment here.

Leave a Reply

Please log in using one of these methods to post your comment:

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