Working with CocoaPods Lib Locally

CocoaPods icon

You already have a Lib created and want to install it in other Projects via CocoaPods, but still wants to work locally with both Lib and the other projects.

To do that, you will need to create the Podspec file. This file is where it will contain all the information about your Lib (Version, name, description, dependencies, author etc).

It will only be possible to place this Lib in other projects using CocoaPods if the Podspec file and with all required fields filled in.

There is a command to create your automatic Podsepc with all fields being reported to fill.

Before telling you which command there are extremely important details.

The name of Podsepc should be the same as the project, if not, when trying installed by the pod install on the other libs, it will not be found.

To create Podspec you should be inside the Project folder (your lib)

cd ~/Workspaces/SomeLib
  // Will create the file SomeLib.podspec
pod spec create SomeLib
  // or
  // Will create the file SomeLib.podspec and will fill   
// automatically some inputs.
pod spec create

Note: If you use the git url. You should pay attention to the name of the project there.


If you are using https://github/some-lib.git and the name of your Lib is SomeLib, the pod spec command will create a file called some-lib.podspec. Because was based on the name of the project that is in github. In this case you will need to change the Podspec name to SomeLib.podsepc.

After adding all necessary Podspec information you should register a local repository

pod repo add name-to-refer-your-repo-locally ~/Workspaces/SomeLib

After you add your repository, you’ll need to push it. It will be necessary to be within the project.

pod repo push name-to-refer-your-repo-locally SomeLib.podspec

Now your Lib is ready to be used in any other project.

In the other project Podfile just add the following line:

target 'SomeProject' do
  pod 'SomeLib', :path => '~/Workspaces/SomeLib' # Row to be added

Added the Lib line in Podfile, just run the pod install command and your Lib will be installed.