Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

How to create CocoaPods

Natalia Terlecka

February 25, 2024

Min Read
How to create CocoaPods

How do I create Cocoapods?

Ever since I found out about CocoaPods I've enjoyed using it, and the fact is that the whole iOS community is using it as well. However, I found out that the current resources and tutorials about CocoaPods make the task of creating one appear so much harder than it actually is.

So, to explain just how easy it is, here are the steps I ended up doing to turn my CameraManager (more about it here) project into a very simple CocoaPod and that you can replicate for your own projects:

Step 1 - Go to your project folder and execute:

Step 2 - After reviewing the generated file, I was left up with the essence of podspec which is:

And here you should focus on the last line that specifies the source files of your CocoaPod. Make sure you include all of them, you'll get snippets for adding more than one file in the generated podspec, and make sure that you include the whole path to the file.

The other notice here goes to the s.source :tag, it's a tag you want users to download the repo with to match the version they want. Every time you create a new version of the repo you need to push the updated podspec file as well as the very same tag name you put in there to your own GitHub repo.

Step 3 - Run:

to see if the file you created will work and solve all the errors and warnings you'll get with the help of Google.

Step 4 - Push validated podspec file to your project repo.

Step 5 - Test on some random project if it works correctly with a podfile:

Step 6 - Create a trunk account if it's your first CocoaPod:

Step 7 - Finally, from the root directory of you project, push the created CocoaPod to the main repo:

After a few minutes, enjoy your opensource library that's easy to use for all iOS developers out there!

Ready for a UX Audit? Book a free call

Found this article useful? You might like these ones too!

blue arrow to the left
Imaginary Cloud logo
blue arrow to the left
Imaginary Cloud logo
blue arrow to the left
Imaginary Cloud logo
blue arrow to the left
Imaginary Cloud logo
blue arrow to the left
Imaginary Cloud logo
blue arrow to the left
Imaginary Cloud logo
blue arrow to the left
Imaginary Cloud logo
blue arrow to the left
Imaginary Cloud logo
blue arrow to the left
Imaginary Cloud logo
blue arrow to the left
Imaginary Cloud logo
blue arrow to the left
Imaginary Cloud logo
Natalia Terlecka
Natalia Terlecka

A senior iOS developer who is part of an agile iOS team and empowers individuals in achieving their dreams and goals.

Read more posts by this author

People who read this post, also found these interesting:

arrow left
arrow to the right
Dropdown caret icon