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
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
.
The output will become as below if we skip this step. - Add
pod 'testPrivatePod', :path => '~/.cocoapods/repos/testPrivatePod'
in podfile pod install
(first time) orpod update
We are good to go.- Now we are feel free to import
<testPrivatePod.h>
If you need a local git system without push to any git repo.
Use pod repo add testPrivatePod /FILE_PATH/testPrivatePod/testPrivatePodRelease
instead.
In this way the private pods will reference to local copy. Only if you do a local git commit, the CI will copy the new files to private pods path. So you can still feel free to change anything before doing git commit
with podspec file
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
|
|
Edit .podspec
until there is no complain by pod lib lint
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
Push podspec File
Push podspec to the place where teammates can access.
For example https://github.com/hsin919/testPrivatePod.git.
In this way, they can use your pods as private pod though pod repo add testPrivatePod https://github.com/hsin919/testPrivatePod.git
Update LIB
Finally, let’s make an upgrade for our universal library.
- Add
+ (void)printTest;
intestPrivatePod.h
&testPrivatePod.m
- Rebuild the project and replace
libtestPrivatePod.a
in testPrivatePod - Increase version number for example
s.version = "0.0.9"
intestPrivatePod.podspec
for example. pod lib lint
to double check podspec is correct- Commit changes for example.
The CI machine will update to version 0.0.9 in next autobuild.