Creating CocoaPods

In this lesson

Say you have a snazzy library that you have been working on. Are you wondering how to get started with posting that to CocoaPods? Well here are some first steps towards that!

Kyle Roberts
Swift Guru at Large

Kyle's Series

Transcript

Tap on time to skip ahead

00:11

Hello world, Kyle here with brax.tv and let’s talk about getting started with creating a brand new CocoaPod. And by that I mean actually creating a library that anyone using CocoaPods can find on CocoaPods.org or GitHub and download and install to their projects with CocoaPods.

00:34

A good way to start with that is to head into Terminal and navigate to the directory that you’d like to begin working, on this new third party library. And if you already have some existing code that you would like to add to CocoaPods as this is a totally optional step but I would still recommend it as it will still help you get started. And once you’re in that directory, you want to type pod lib create and the name of the pod that you’re going to be creating. Let’s just call this example here, Brax. So that’s going to run some code and start creating a new Xcode project and CocoaPods configuration for us to work with. And we can see that it is downloading this template from GitHub.

01:25

And the first question is going to ask us is what language do we want to use and just so you know a few of the questions are different or there are different options depending on the answers you give. Just for example some things are required or included with Swift that may not be so in Objective-C. Would we like to include a demo application? Sure. Testing frameworks, how about Quick and Nimble. View based testing, yes. I’m just going to answer yes to almost everything here.

01:59

But then appeared to be the last question. And what this is actually doing in this new Xcode project that it creates for us, let’s open that back up, is that it creates the project for us to develop our library in, as well as the demo application project into the demo application project. It’s installing this new dependency that will be working on here, locally, as well as anything else that was referenced from those questions we had the answer. You can see that it’s installing Quick and Nimble because we did say yes we wanted to use those testing frameworks as well as FBSnapshotTestCase and it installs those pods to the demo application and opens it up for us.

02:46

So this demo application that it created for us is basically blank. There is an empty normal Xcode single view template or something like that that it creates. And in this Podspec Metadata folder, it creates something called Brax.podspec. Which is something important when creating your own CocoaPod but we will not get to that just yet. Some other things it creates are a ReadMe file and a license.

03:15

Now when submitting your own CocoaPod, at least to CocoaPods.org as a public resource there are few things required. And that is your actual library, the code that will be installed when it is included in a podfile, the podspec which is the definition and configuration of your CocoaPod, this is something that you upload to CocoaPods.org so that CocoaPods can file it away and includes directions for when users install it. And two other things that are required when uploading your own public CocoaPod is a ReadMe and license which it creates here for us.

03:57

But if you do not have one since you are working in an existing project. this is my SteamReader app, not necessarily a third party resource, but in the folders for SteamReader, I had not had a license, ReadMe or podspec before I had set this up. And of course we are in a different directory for this video and we can explore the file system that it creates, a shortcut to this pods project, a Brax directory which is the actual third party resource that we’ll be creating the podspec, an example directory which contains that Xcode project that we just had open, ¬†which has installed our Brax pod, and then of course the license and ReadMe.

Additional Info

Register to get access to additional resources and info.