# Best practice for use of cached Cocoapods specs

**URL:** <https://discuss.circleci.com/t/best-practice-for-use-of-cached-cocoapods-specs/18897>\
**Category:** Mobile\
**Tags:** ios\
**Created:** [December 18, 2017, 6:33pm UTC](https://discuss.circleci.com/t/best-practice-for-use-of-cached-cocoapods-specs/18897 "2017-12-18T18:33:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbelkins](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jbelkins/32/17515_2.png) [@jbelkins](https://discuss.circleci.com/u/jbelkins)\
**Post date:** [December 18, 2017, 6:33pm UTC](https://discuss.circleci.com/t/best-practice-for-use-of-cached-cocoapods-specs/18897/1 "2017-12-18T18:33:22Z")

</div>

We retrieve cached Cocoapods specs, as recommended, with the following shell command:  
curl -sS [https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh](https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh) | bash

Last week I ran a build and it failed because one of my podspecs was not yet in the cached repo - it had been published just that day. I reran my build at a later time and it passed, presumably because the cache had been updated from the master Cocoapods repo with the podspec I needed.

What is the best practice to avoid such failures in the future? Should I use the --repo-update option when I do my pod install, to get the latest specs that aren’t yet in the cache, or is there a better way?

(Also, just for my curiosity, how frequently is CircleCI’s podspec cache updated from the master repo?)

---

<div class="post-metadata">

**Author:** ![DanToml](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/dantoml/32/17087_2.png) [@DanToml](https://discuss.circleci.com/u/DanToml)\
**Post date:** [December 27, 2017, 10:54am UTC](https://discuss.circleci.com/t/best-practice-for-use-of-cached-cocoapods-specs/18897/2 "2017-12-27T10:54:08Z")

</div>

Hey! - The CocoaPods repo cache is updated roughly every 30 mins, which is usually frequent enough to only miss the last 6 pushes to the Specs repo.

If you find yourself in a position where this is a frequent problem (such as pushing and updating an internally maintained pod regularly), I’d highly recommend checking in your Pods/ directory, as this frequently saves a fair amount of CI time, alongside its other benefits.

---

<div class="post-metadata">

**Author:** ![ilyapuchka](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/ilyapuchka/32/11824_2.png) [@ilyapuchka](https://discuss.circleci.com/u/ilyapuchka)\
**Post date:** [April 17, 2018, 9:01pm UTC](https://discuss.circleci.com/t/best-practice-for-use-of-cached-cocoapods-specs/18897/3 "2018-04-17T21:01:41Z")

</div>

@DanToml Is there a recommended way to save time (it takes roughly 3-4 minutes) even on loading the specs if nothing changed, meaning Podfile and Manifest lock files match? I’ve tried only downloading specs from the mirror if those file differ but then `pod install` starts to clone the main specs repo, as I guess there is none in a workspace. And I’m not sure that just including `~/.cocoapods/repo` is a safe thing to do here.

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [April 17, 2018, 10:34pm UTC](https://discuss.circleci.com/t/best-practice-for-use-of-cached-cocoapods-specs/18897/4 "2018-04-17T22:34:10Z")

</div>

> [@ilyapuchka](#):
>
> Is there a recommended way to save time (it takes roughly 3-4 minutes) even on loading the specs if nothing changed, meaning Podfile and Manifest lock files match

I’m not familiar with this technology, but would I be right in thinking that this downloads library dependencies based on one of the files you mention? If so, it sounds like the CircleCI `restore_cache` and `save_cache` devices would be helpful here - you can do a checksum on that file, so that it only re-downloads if the file changes.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [July 16, 2018, 10:34pm UTC](https://discuss.circleci.com/t/best-practice-for-use-of-cached-cocoapods-specs/18897/5 "2018-07-16T22:34:18Z")

</div>

Closed on July 16, 2018, 10:34pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
