• Stars
    star
    451
  • Rank 96,968 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CocoaPods binary cache

Test License Gem

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.

Installation

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.11"

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-cache

How it works

Check out the documentation on how it works for more information.

Usage

1. Configure cache repo

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. Specify this cache repo in the following section.

2. Configure Podfile

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(
  cache_repo: {
    "default" => {
      "remote" => "git@cache_repo.git",
      "local" => "~/.cocoapods-binary-cache/prebuilt-frameworks"
    }
  },
  prebuild_config: "Debug"
)

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 => true

NOTE:

  • Dependencies of a prebuilt pod will be automatically treated as prebuilt pods.
    For example, if RxCocoa is declared as a prebuilt pod using the :binary => true option, then RxSwift, one of its dependencies, is also treated as a prebuilt pod.

3. CLI

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 push

For each command, you can run with option --help for more details about how to use each:

$ bundle exec pod binary fetch --help

4. A trivial workflow

A 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 install

For other usages, check out the best practices docs.

Benchmark

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.sh

In 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.

Known issues and roadmap

Exporting IPA with Bitcode

  • When exporting an IPA with Bitcode, remember to disable the rebuild from bitcode option. Refer to #24.

Pods with headers only

  • By default, pods with empty sources (ie. pods with header files only) will be automatically excluded and they will be later integrated as normal. For now, we rely on the source_files patterns declared in podspec to heuristically detect empty-sources pods.
  • However, there are cases in which the source_files of a pod looks like non-empty sources (ex. s.source_files = "**/*.{c,h,m,mm,cpp}") despite having header files only. For those cases, you need to manually add them to the excluded_pods option.

Best practices

Check out our Best practices for for information.

Troubleshooting

Check out our Troubleshooting guidelines for more information.

Contribution

Check out CONTRIBUTING.md for more information on hw to contribute to this repo.

License

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.

More Repositories

1

front-end-guide

πŸ“š Study guide and introduction to the modern front end stack.
JavaScript
14,933
star
2

cocoapods-pod-merge

Cocoapods plugin to merge pods used by your Xcode project, reducing the number of dynamic frameworks your app has to load on startup
Ruby
363
star
3

Grazel

A tool to migrate Android projects from Gradle to Bazel incrementally and automatically
Kotlin
246
star
4

engineering-blog

πŸ“ We write about our technologies and the problems we handle at scale.
Ruby
119
star
5

swift-leak-check

Swift
109
star
6

talaria

TalariaDB is a distributed, highly available, and low latency time-series database for Presto
Go
108
star
7

secret-scanner

Go
40
star
8

grab-bazel-common

Common rules and macros for Grab's Android projects built with Bazel.
Kotlin
35
star
9

hackathon

πŸ’» Official Grabathon websites
JavaScript
29
star
10

symphony

Go
28
star
11

grabplatform-sdk-js

GrabPlatform SDK in javascript
TypeScript
27
star
12

async

Go
24
star
13

grabplatform-sdk-android

GrabPlatform SDK for android
Kotlin
20
star
14

superapp-sdk

SDK for Grab SuperApp WebView.
JavaScript
15
star
15

grabplatform-sdk-ios

GrabPlatform SDK for iOS
Swift
12
star
16

GraphBEAN

Interaction-Focused Anomaly Detection on Bipartite Node-and-Edge-Attributed Graphs
Python
11
star
17

grab-query-traces

10
star
18

grabpay-merchant-sdk

Java
9
star
19

gosm

Gosm is a golang library which implements writing OSM pbf files.
Go
9
star
20

mobile-kit-bridge-sdk

SDK for web view bridges that offers unified method signatures for Android/iOS
TypeScript
7
star
21

grabplatform-sample

Comprehensive sample for GrabPlatform-related SDKs.
JavaScript
4
star
22

blogs

Accompanying source code for our engineering blog
Ruby
4
star
23

grabplatform-sdk-golang

GrabPlatform SDK for Golang
3
star
24

grabplatform-sdk-js-example

JavaScript
1
star
25

go-showdeps

Go
1
star