DZone
Mobile Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Mobile Zone > Private Pod Support Using CocoaPods in iOS

Private Pod Support Using CocoaPods in iOS

Learn how to manage your mobile development projects by using a dependency manager tool that allows you to manage external libraries.

Kirit vaghela user avatar by
Kirit vaghela
·
Mar. 28, 17 · Mobile Zone · Tutorial
Like (6)
Save
Tweet
4.80K Views

Join the DZone community and get the full member experience.

Join For Free

You might have read our recent blog on SDUI framework that introduced the concept of UI presentation made easier by eliminating the need for frequent updates to an application by the end user. It is built and deployed with just “one code base logic” and is applicable for each of the UI releases while eliminating the need for frequent updates of the Apps.

The framework can be of used in other iOS projects; hence it requires a lot of effort in manually installing and building it. Therefore, to overcome this challenge the team explored various options and found a more centralized solution, ‘CocoaPods’ - a dependency manager tool that provides a standard format for managing the external libraries. It has over 27 thousand libraries and is used in over 1.6 million apps and can help scale any project elegantly. It focuses on the source-based distribution of third party code and automatic integration into Xcode projects.

Getting Started

The dependencies for projects are specified in a single text file called a Podfile. CocoaPods will resolve the dependencies between libraries, fetch the resulting source code, and then link it together in the XCode workspace to build your project.

Image title

Follow the Below Steps to Add Private Pod in Your Ios Project:

By default, CocoaPods uses a public specification repository (https://github.com/CocoaPods/Specs). If you want to make your pod private then you have to create a private repository with the same structure and upload your pod specification file to the private repository.

Installation

1. CocoaPods is built with Ruby and it will be installable with the default Ruby available on Mac OS. Using the default Ruby install will require you to use “sudo” when installing gems.

2. Follow the below command to install Cocopods in your system:

$ sudo gem install cocoapods


Create a pod specification file (.podspec file).Create and Use Cocoapods in Your Ios Project

  • The specification file contains detailed information about the repository. When you execute pod install or pod update commands, CocoaPods will look into the specification file and clone the repository.

Follow the Below Steps:

1.Create a specification for your pod using the following command:

$podspec create <your_pod_name>

Example: pod spec create AppUtils

2.Edit the AppUtils.podspec

  • Name – name of the pod.
  • Version – the current version for the specification. Your repo must contain a tag for the version number. i.e. 1.0,1.2 etc.
  • Summary – a short summary of project.
  • Description – detailed description of the project.
  • Homepage – homepage of the project.
  • License – license for the project, i.e – MIT,BSD.
  • Author – author of the repo.
  • Platform – OS and version used in the repo, i.e. iOS 9.0.
  • Source – source URL of the repo.
  • source_files – files to be included in the pod.
  • exclude_files – files not to be included in the pod.
  • Dependency – any third party dependency for the pod project.

3.Now verify the pod spec file by using the following command:

$ pod spec lint AppUtils.podspec

Image title

  • Solve any error or warning that may occur while validating .podspec file

4.Now upload the specification file to your specification repository.

CocoaPod is using a public specification repository for the public pod. If you want to create a private pod then you have to create your own private specification repo that will store.podspec files.

Image title

Each version has its own specification file. Your specification repository can have more than one specification.Image title

5.Specifying a private pod in Podfile.

If you are using a private pod then you have to tell CocoaPod, where the specification repository is located by specifying the source at top of the Podfile:

Source “<path of your privatespecification git repo> "
pod 'AppUtils', '~> 1.0'


If you don’t want to create a private specification repository then create the same specification structure in your project and specify the repository URL as the source in the Podfile.

Image title

Benefits

CocoaPods are widely used for third party dependency integration. Below are few benefits of using CocoaPod over manually managing Dependencies in your project.

  • Managing dependencies in your code is simplified by downloading all of them when you run the pod install/update command.
  • Manually added dependency may not be easy for another coder to locate it. Pods ensure that one can easily go through the pod scheme or a Podfile to understand all the dependencies used in the project.
  • The task of replacing a library with a new version is simplified with CocoaPods automatically by using only one command instead of manually deleting old files and adding new ones.

Conclusion

Private pods make managing your project much simpler. It saves a lot of effort and time when dealing with dependencies in your project. Also, we can use this pod privately for internal access.

pods CocoaPods Repository (version control) Dependency

Published at DZone with permission of Kirit vaghela. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Internal Developer Platform in Plain English
  • Java’s Encapsulation - When the Getter and Setter Became Your Enemy
  • Blocking Ads on Your Network Using Raspberry Pi 3 + Fedora + Pi-hole
  • API Security Weekly: Issue 165

Comments

Mobile Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo