Create CocoaPod Using Swift

Every project starts with an architecture and reusable components that help us to develop mobile applications much faster.

In this article you will learn how to create a simple CocoaPod framework using Swift language.

What you need

Open terminal and go into project folder

cocoapod1
  1.  Now you have created projectChange .podscpec file content
CocoaPod


2. Write your code

Click here to see the example.


3. Submit your pod

Tag your most recent commit and push it to the remote.


This step indicates that you are marking this commit as a specific release of your pod. The name of the tag should match s.version in your .podspec file. The next step will validate this.

Next, run the following command from the command line to verify that everything is correctly configured between the location of your source code and your .podspec file:

cocoapod

This should output the following:

cocoapod 4

Finally, push the spec to the Specs repository by executing the following command:

cocoapod

This should output the following: click here.


Result

You now have your own pod ready to use. Just add it to a new project in Podfile and use it.

cocoapod 6

Remember, if you spend some time with library now, you will be able to reuse it in future projects for days, week, even years!


vialyx

 Maxim Vialykh is CactusSoft iOS Tech Lead.

Technical Background
Programming languages: Swift, Objective-C, Java
Technologies and Platforms: iOS, Android, Windows Phone, Amazon S3, Google Cloud, Google APIs, Facebook APIs
Frameworks: PhoneGap, Xamarin
Tools: Invision, SVN, Git, PhoneGap, Titanium, Xamarin, Sketch, xCode, IntelliJ IDEA

Share this page
If there is a project needing help or even a skill set you are missing, contact us.
Subscribe To Our Newsletter
To get new inspiring articles and news right in your inbox.