Publish Your Cocoapod! – Public Open Source Publish

In this lesson

It’s finally time to share your CocoaPod with the world! I’m excited too. Really, its just one simple command to upload your CocoaPod, but your process may be a little more involved. I’ve got you covered.

Kyle Roberts
Swift Guru at Large

Kyle's Series


Tap on time to skip ahead


Hello world, Kyle here with and I’m going to talk about what you need to do to publish your own personal third party library to for public open source consumption. And what I mean by that is that hopefully by the end of this, if you do you have your own library, you will be able to publish it to And as soon as they have indexed your library submission, then you should be able to find it on pod search just straight from their homepage by typing in some details or the name of your resource. And to be able to actually use it when installing pods from a typical CocoaPods user standpoint.


So in this case, if I were to publish this example, which I’m actually just using a standard Xcode project for example and not a real third party resource or library, you would be able to install it just by referencing it in your podfile. So then you need to do there is to navigate to the directory that your podspec is in, and in this case mine’s in the SteamReader directory, the same directory to find on the GitHub repo for this. Also, this is assuming that you have already registered your name, email, and device with CocoaPods via something called Trunk. And you just use that command to do so. And one other thing this is assuming is that the repo of your library is publicly available. And that means open source library to be a public GitHub project and completely open source where I’m the manager and anyone can see any of the code.


One way around that if you want to keep some of your code private is to compile some of your stuff into a framework. In my experience that is much easier to do with Objective-C, but not Swift. Though CocoaPods, you know, does work for both those languages. So since you’re creating a public CocoaPod, then the code and the podspec both need to be somewhere public. And typically the podspec is within the same repo as the rest of the code.


So assuming both of those things, you just need to run one command and that is pod trunk push and then the name of your podspec. So I would actually replace this with SteamReader.podspec to actually point at this podspec that I’ve configured here. And what happens when you run this, I’m not actually going to run it because I don’t want by any chance for this to be published to CocoaPods. Again, it’s an iPhone app, it’s not a library. But what’s going to happen here is it’s going to run a lint check and that’s actually going to attempt to build the code within your library.


And assuming all goes well there, it you can find your source, the source is marked with the appropriate version numbers, everything in the code matches what’s in the podspec and vice versa. And then using your active Trunk registration and authentication, it’s going to push that to And you will do the same thing to actually update an existing podspec or CocoaPod. Say I already had a version existing of SteamReader library on CocoaPods, then doing this would just update what was already there. And it’s as simple as that to publish your CocoaPod for public use.

Additional Info

Register to get access to additional resources and info.