Fixing local problems with a Carthage version number

As I discussed previously, we are using Carthage and Git submodules to manage our dependencies. Since many of the frameworks that we are pulling in are frameworks that we are writing, we sometimes run into an issue where we have changed the version number of a release for a framework to be the same as a previous version. This does not happen often, but can happen if you have made a release, and then later deleted the release and the tag and made a new release pointing to a different commit.

The problem is that when you update a framework via a Carthage dependency, a local cache of the repo is saved, along with the version number tags. If you change your Cartfile to reference a version number that was previously downloaded, Carthage will use the locally cached version instead of getting the latest update from GitHub.

Solution

  1. Using Terminal, navigate to the Carthage cache.
    • cd /Users/[username]/Library/Caches/org.carthage.CarthageKit/dependencies
  2. Remove the directory matching the framework that you need to force to download.
    • rm -rf FrameworkName/
  3. Back in your project directory, update again from Carthage.
    • carthage update --no-build --use-submodules
    • Edit: carthage checkout works better for this. Thanks Tim Shadel!

Summary

Your framework will download from GitHub at whatever version number you have specified, and you should be set. This is mostly a reference for myself for the next time that I need to remember how to do this, but hopefully it can help you as well.

Related Posts

Updating layouts for iPhone X

An ongoing summary of lessons learned from updating designs for the iPhone X

Public drafts with a GitHub Pages blog

Improve the process of publishing from anywhere by previewing drafts on your actual site

Using Workflow to publish to GitHub Pages

Leverage the power of automation to reduce friction in publishing from anywhere

Adding automation to open-source projects

Improving projects and increasing self-guilt with Travis, Slather and Codecov

Handling live text reload elegantly

Easy steps to support concurrent editing without losing cursor position or text selection in UITextView