How to Create Private Pod
This document shows two samples which are made under cocoapods version 0.36.0.beta.1
- testPrivatePod : A private pod with an universal library
- testUsePod : Project use private pod
We will go though
* How to use private pod created by teammates
* How to create private pod for existing universal library
<!-- more -->
Cocoapods
cocoapods is a very useful tool which manage frameworks/package for xcode.
People share lots of pods which can be found in the place as cocoapods search
By creating podspec, we can create our own pod to make module reuseable.
It's also possible to publish your pod by using pod trunk push POD_NAME.podspec
.
Only one line pod 'POD_NAME'
needed to be added in podfile
, People can use your pod in their project.
What is Private Pod
Image that we are using a large core library which is implemented for company inner usage in various projects. For example, an universal fat library named testPrivatePod.a.
https://github.com/hsin919/testPrivatePod/
Everytime the CI release a new build testPrivatePod need to be cloned to local machine.
Private pod solve this problem.
cocoapods will check if there is any update for testPrivatePod.
The download will be triggered only if there is a new version.
How to Use Private pod Created By Teammates
- Add private pod to local.
pod repo add testPrivatePod https://github.com/hsin919/testPrivatePod.git
. You can double check if it's success under~/.cocoapods/repos/testPrivatePod
. <a href="https://www.flickr.com/photos/hsin919/16319653707" title="afteraddprivatepod by hsin chang, on Flickr"></a> The output will become as below if we skip this step. <a href="https://www.flickr.com/photos/hsin919/16498838861" title="No spec by hsin chang, on Flickr"></a> - Add
pod 'testPrivatePod', :path => '~/.cocoapods/repos/testPrivatePod'
in podfile -
pod install
(first time) orpod update
We are good to go. <a href="https://www.flickr.com/photos/hsin919/16313133020" title="updateLib by hsin chang, on Flickr"></a> - Now we are feel free to import <testPrivatePod.h>
Create Private pod for existing universal library
Assume we got the .h .a files on https://github.com/hsin919/testPrivatePod without the podspec file.
Create podspec
pod spec create testPrivatePod
pod lib lint
Edit .podspec
until there is no complain by pod lib lint
<a href="https://www.flickr.com/photos/hsin919/16474576496" title="lib lint fail by hsin chang, on Flickr"></a>
Details of podspec
-
s.source = { :path => '*.{h,a}' }
Specify the location from where the source should be retrieved. -
s.source_files = "*.{h}"
In the case of testPrivatePod onlytestPrivatePod.h
is source code. -
s.library = "testPrivatePod"
,s.preserve_paths = "libtestPrivatePod.a"
ands.xcconfig = { 'LIBRARY_SEARCH_PATHS' => '~/.cocoapods/repos/testPrivatePod' }
make pod project settings link to corresponding library afterpod update
Update LIB
Finally, let's make a upgrade for our universal library.
1. Add + (void)printTest;
in testPrivatePod.h
& testPrivatePod.m
1. Rebuild the project and replace libtestPrivatePod.a
in testPrivatePod
1. Increase version number for example s.version = "0.0.9"
in testPrivatePod.podspec
for example.
1. pod lib lint
to double check podspec is correct
1. Commit changes for example.
The CI machine will update to version 0.0.9 in next autobuild.