# How to cache CocoaPods dependencies

**URL:** <https://discuss.bitrise.io/t/how-to-cache-cocoapods-dependencies/193>\
**Category:** Caching\
**Tags:** build-cache\
**Created:** [January 9, 2017, 6:30pm UTC](https://discuss.bitrise.io/t/how-to-cache-cocoapods-dependencies/193 "2017-01-09T18:30:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 9, 2017, 6:30pm UTC](https://discuss.bitrise.io/t/how-to-cache-cocoapods-dependencies/193/1 "2017-01-09T18:30:09Z")

</div>

## Setup

_(If not added already)_

1. Put the `Cache:Pull` step after the `Git Clone` and before the `CocoaPods Install` steps
2. Put the `Cache:Push` step to the very end of the Workflow

**_If you use v1.0 or newer of the Cache steps and the latest CocoaPods Install step then that’s all you have to do._**

* * *

_For older versions please follow these additional steps:_

1. Select the `Cache:Push` step and specify the following paths for caching ( **Cache paths** input):

```auto
./Pods -> ./Podfile.lock

```

```auto

_If your Podfile and Pods directory is not in the root of your repository then you should specify the path relative to the repository root, e.g. `./subdir/Pods -> ./subdir/Podfile.lock`_

That's all. This specification (using the `->` indicator) means that the `./Pods` directory should be cached, and that the cache should be updated only if the `./Podfile.lock` file changes.

## Example workflow

```

example:  
steps:

- git-clone: {}
- cache-pull: {}
- cocoapods-install:
- certificate-and-profile-installer: {}
- xcode-archive:
- cache-push:  
inputs:
  - cache\_paths: “./Pods → ./Podfile.lock”

```auto

__For more information about the Bitrise Build Cache see the [DevCenter](http://devcenter.bitrise.io/caching/about-caching/).__
```

---

<div class="post-metadata">

**Author:** ![jpgarcia](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/jpgarcia/32/1291_2.png) [@jpgarcia](https://discuss.bitrise.io/u/jpgarcia)\
**Post date:** [March 10, 2018, 2:41pm UTC](https://discuss.bitrise.io/t/how-to-cache-cocoapods-dependencies/193/2 "2018-03-10T14:41:59Z")

</div>

Hi @viktorbenei I’m trying to use the cache push task but it doesn’t work. Podfiles are downloaded on each build.

Below is my cache publish task for a React Native project . Can you check if I’m doing something wrong?

I don’t really understand what the “-\>” means. Are two cache items? or is that the Pods folder depends on the Podfile.lock file? I’m following the same approach for the yarn modules.

**NOTE** : The cache pull if before the yarn task and the cache push is the last one as described in the docs.

Thanks in advance

```
_cache-publish:
    envs:
    - BUILD_ENV: testing
    after_run: []
    steps:
    - cache-push@2.0.5:
        inputs:
        - cache_paths: |-
            $HOME/.gradle
            ./packages/mobile/ios/Pods -> ./packages/mobile/ios/Podfile.lock
            ./node_modules -> ./yarn.lock
            ./packages/backoffice/node_modules -> ./yarn.lock
            ./packages/backend/node_modules -> ./yarn.lock
            ./packages/web/node_modules -> ./yarn.lock
            ./packages/loadtest/node_modules -> ./yarn.lock
            ./packages/core/node_modules -> ./yarn.lock
            ./packages/mobile/node_modules -> ./yarn.lock
        - ignore_check_on_paths: |-
            $HOME/.gradle/caches/*.lock
            $HOME/.gradle/caches/*.bin
            ./.gradle/*.lock
            ./.gradle/*.bin
```

---

<div class="post-metadata">

**Author:** ![jpgarcia](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/jpgarcia/32/1291_2.png) [@jpgarcia](https://discuss.bitrise.io/u/jpgarcia)\
**Post date:** [March 11, 2018, 4:01pm UTC](https://discuss.bitrise.io/t/how-to-cache-cocoapods-dependencies/193/3 "2018-03-11T16:01:42Z")

</div>

just found the “-\>” explanation in the workflow editor by clicking the “Change” button and got it working

> You can also specify an “update indicator file” with the → syntax: update/this → if/this/file/is/updated. The indicator can only be a file!
> 
> If you have a path in the list which doesn’t exist that will not cause this Step to fail. It’ll be logged but the Step will try to gather as many specified & valid paths as it can, and just print warning about the invalid items.

Thanks!

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [March 13, 2018, 3:41pm UTC](https://discuss.bitrise.io/t/how-to-cache-cocoapods-dependencies/193/4 "2018-03-13T15:41:55Z")

</div>

That’s right @jpgarcia, we should update the DevCenter to include this - I think right now it’s only explained in the step’s description. That said… it’s actually a step related thing, the caching API supports any cache artifact file - you can even write your own cache steps, it’s just a file storage API on the backend side 😉 The `->` syntax is purely a step defined convention.
