iOS – How to create a private CocoaPods library?

Create a pod library

Generate a template Pod library project

  • Install cocoapods
sudo gem install cocoapods
  • Close all terminals, reopen 1 terminal
pod --version
  • Generate pod library using an existing template
pod lib create MyCocoapodsLibrary

Create a dummy Pod class

  • Create a Logger class
  • Open a terminal inside Example project and run
$ pod install
  • Back to XCode, run the app, you can see the log is printed

Push Pod library into remote repo

Configure podspec file

  • Edit podspec file
  • Check if podspec file is set correctly
pod lib lint

Create remote repo

  • Create an empty remote repo
  • Point your pod library project’s remote repo to the above repo
  • Create a tag 0.1.0
  • Push codes

Create a PodSpec repository

Setup PodSpec

  • Create a folder structure like this and copy MyCocoapodsLibrary.podspec from the above pod project into this
  • Push this into git repo
    • Create an empty git repo
    • Setup local git
// cd into folder containing MyCocoapodsLibrary
git init
git add .
git commit -m "Inital commit"
git remote add origin https://github.com/hung-nb/react-native-new-pod-lib.git
git push origin master

Use this pod lib in a project

  • Initialise pod inside iOS project
    pod init
  • Edit podfile
    code podfile

How to use private remote pod repo (in progress)?

  • Run this to install podspec git into local
    pod repo add MyCocoapodsLibrary https://github.com/zzzzzzzzz/your-podspec-github.git

How to use local pod?

  • Add this into your podfile

Be the first to comment

Leave a Reply

Your email address will not be published.


*