Making Your Own CocoaPods — Part 3

Bharghav Kumar
3 min readFeb 24, 2019
Utilization of private cocoapods

So far, learn how to install cocoapods and it’s creation as well as distribution in both ways i.e. private and public. In this story, you are going to learn how to the utilise your own cocoapod which was distributed privately in the last part. Assuming you know how to utilise cocoapods which were available as public.

Private Cocoapods Utilization

There are few steps should follow by everyone in the team before utilizing private cocoapods by assuming everyone knows pod installation process.

  1. Everyone should have access to the private spec repo
  2. Everyone should add the private spec repo into their local cocoapod installation directory (i.e ~/.cocoapods/repos/) with the following command
  3. Remote URL of the private spec repo should specify at the top of the project Podfile. So that pod install command knows where to find the required pods location to install into the project.
$ pod repo add [REPO_NAME] [REMOTE_URL]

Let’s dive into the demonstration with an example project.

Demonstration

Create a new project to install own private cocoapods using source URL of private spec repo as following

Creating a new project

After project creation, need to create podfile in the project directory. The Podfile is a specification that describes the dependencies of the target of one or more Xcode projects. Run the following commands to create pod file

$ cd [PROJECT_DIRECTORY]
$ pod init
$ open -a Xcode podfile

By the last command, Xcode opens Podfile to edit. Add private spec repo source URL and private cocoapod as shown below

After Podfile modification, close Xcode and move on to the terminal again to run pod install as shown below

$ pod installAnalyzing dependencies
Downloading dependencies
Using my_own_cocoapod (0.0.1)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

Cocoapod creates .xcworkspace after successful completion of pod installation process. Now onwards when you want to edit your project, open xcworkspace rather than xcodeproject. The workspace contains your project along with the dependencies as shown below

Project Navigator after pod install

Congratulation! I’m going to ending this series here by assuming you know everything from here.

Conclusion

I hope everyone understands about Cocoapods and its advantages. I’m hoping that it helps a lot for the developers whoever thinking to modularize their code into libraries by segregating reusable code, utilities, extensions and so on.

Hope you rejuvenate your skills with this series of stories. If you have any troubles and suggestions please mention in the comments and reach me out on my mail (ID: cbk2604@gmail.com) as well. Good luck my friends will see you in future stories. Keep following me.

All the Best

--

--