Skip to content

Instantly share code, notes, and snippets.

@gauravkeshre
Created January 13, 2019 20:58
Show Gist options
  • Save gauravkeshre/ca27067ace17f62a5dfc7d65061012d4 to your computer and use it in GitHub Desktop.
Save gauravkeshre/ca27067ace17f62a5dfc7d65061012d4 to your computer and use it in GitHub Desktop.
Pocket reference to creating private cocoapods

Pocket reference to creating private cocoapods

Git repositories

This process requires you to create 2 git repositories.

  1. pod-specs repo 1.1 This repo holds the specs for all the private pods. 1.2 You only have to create this once per organization (assuming your private pods are limited to an organization)

  2. Library repo 2.1 This repo contains the code of the component/library that you need to reuse and import in other projects using pod install 2.2 You will create one such repo for every component you need to access

When using private pods as part of main code base

Refer this gist There are cases when you want to create pods only for beter organizing the components and libraries and still want them to be part of the same code base as your main project.

In such cases you need not create a Library repo.

Steps

1. Create pod-spec repo

If this is not the first private pod in your organization, skip this step.

  1. Create pod-spec repository in your org git (github/gitlab/bitbucket)
  2. In your computer map this repo to a spec using following command
$ pod repo add microsoft-specs https://gitlab.com/ios-components/microsoft-specs

2. Create Library repo

If you are using private pods as part of main code base, skip this step.

  1. In your git tool go ahead and create a new repo.

3. Prepare Library repo (podspec file)

There are 2 ways you can prepare a repo to be used in pods.

1. Use the command pod lib create [POD_NAME]
  • This will create a new project with a standard folder structure.
  • I personally like to use my own folder structre and avoid this technique.

OR

2. Simply create a [POD_NAME].podspec file in your project's root folder
$ touch Alerts.podspec
$ open -a atom Alerts.podspec # you can choose your favorite text editor here
3. create a tag
  • Ensure that the version mentioned in the podspec file and the tag you create are same
$ git tag 0.0.1 
$ git push --tags
4. Validate
  • locally: -- using pod lib lint

  • ovarall -- using pod repo lint

5. Finally, Push

Note that you will repeat step 3, 4, 5 everytime you need to update your pods

You can publish the updates using following command

$ pod repo push microsoft-specs Alerts.podspec --allow-warnings

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment