DZone
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
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Data Engineering
  3. Databases
  4. 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 · Tutorial
Like (6)
Save
Tweet
Share
4.96K 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

  • DevOps vs Agile: Which Approach Will Win the Battle for Efficiency?
  • Is DevOps Dead?
  • 10 Best Ways to Level Up as a Developer
  • DevOps for Developers: Continuous Integration, GitHub Actions, and Sonar Cloud

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • 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: