A plugin that helps to reduce the build time of Xcode projects which use Cocoapods by prebuilding pod frameworks and cache them in a remote repository to share across multiple machines.
Requirements
- Ruby: >= 2.4
- CocoaPods: >= 1.5.0
Via Bundler
Add the gem cocoapods-binary-cache to the Gemfile of your project.
gem "cocoapods-binary-cache", :git => "https://github.com/grab/cocoapods-binary-cache.git", :tag => "0.1.2"Then, run bundle install to install the added gem.
In case you're not familiar with bundler, take a look at Learn how to set it up here.
Via RubyGems
$ gem install cocoapods-binary-cacheCheck out the documentation on how it works for more information.
First of all, create a git repo that will be used as a storage of your prebuilt frameworks. Make sure this git repo is accessible via git clone and git fetch.
Create a json file PodBinaryCacheConfig.json under the root of the project. Specify 2 fields cache_repo and cache_path:
{
"cache_repo": "<your_git_url_goes_here>",
"cache_path": "<path_to_local_git_repo>"
}cache_repo: the git URL to the cache repo, for example https://github.com/username/prebuilt-frameworks.git.cache_path: the path to your local directory in which the cache repo is fetched to, for example~/.cocoapods-binary-cache/prebuilt-frameworks.
2.1. Load the cocoapods-binary-cache plugin.
Add the following line at the beginning of Podfile:
plugin "cocoapods-binary-cache"2.2. Configure cocoapods-binary-cache
config_cocoapods_binary_cache(
prebuild_config: "Debug",
dev_pods_enabled: false
)For details about options to use with the config_cocoapods_binary_cache function, check out our guidelines on how to configure cocoapods-binary-cache.
2.3. Declare pods as prebuilt pods
To declare a pod as a prebuilt pod (sometimes referred to as binary pod), add the option :binary => true as follows:
pod "Alamofire", "5.2.1", :binary => trueNOTE:
- Dependencies of a prebuilt pod will be automatically treated as prebuilt pods.
For example, ifRxCocoais declared as a prebuilt pod using the:binary => trueoption, thenRxSwift, one of its dependencies, is also treated as a prebuilt pod.
We provided some command line interfaces (CLI):
- Fetch from cache repo
$ bundle exec pod binary fetch- Prebuild binary pods
$ bundle exec pod binary prebuild [--push]- Push the prebuilt pods to the cache repo
$ bundle exec pod binary pushFor each command, you can run with option --help for more details about how to use each:
$ bundle exec pod binary fetch --helpA trivial workflow when using this plugin is to fetch from cache repo, followed by a pod installation, as follows:
$ bundle exec pod binary fetch
$ bundle exec pod installFor other usages, check out the best practices docs.
We created a project to benchmark how much of the improvements we gain from this plugin. The demo project is using the following pods:
AFNetworking
SDWebImage
Alamofire
MBProgressHUD
Masonry
SwiftyJSON
SVProgressHUD
MJRefresh
CocoaLumberjack
Realm
SnapKit
Kingfisher
Below is the result we recorded:
Hardware specs of the above benchmark:
MacBook Pro (15-inch, 2018)
Mac OS 10.14.6
Processor 2.6 GHz Intel Core i7
Memory 16 GB 2400 MHz DDR4
You can also try it out on your local:
$ cd PodBinaryCacheExample
$ sh BuildBenchMark.shIn our real project with around 15% of swift/ObjC code from vendor pods. After applying this technique, we notice a reduction of around 10% in build time.

- Support for development pods is currently under development and refactor. You are advised not to use
:binary => truefor development pods until further support.
Check out our Best practices for for information.
Check out our Troubleshooting guidelines for more information.
Check out CONTRIBUTING.md for more information on hw to contribute to this repo.
The cocoapods-binary-cache plugin is available as open-source under the terms of the MIT License. It uses cocoapods-rome and cocoapods-binary internally, which are also under MIT License.
