Skip to main content

Managing dependencies with Carthage

Abstract

You can use Bitrise's official Carthage Steps to install and cache your iOS dependencies. Carthage doesn't alter your Xcode project in any way and managing it requires very little configuration on Bitrise.

Carthage is a dependency manager for iOS and macOS. It's a decentralized dependency manager that doesn't alter your Xcode project in any way. You can use it on Bitrise, too, to handle dependencies for your iOS apps.

Installing Carthage dependencies

To install your dependencies with Carthage:

Workflow Editor

bitrise.yml

  1. Make sure you have a Cartfile included in your project.

  2. Add the Carthage Step to your Workflow.

    It should come after any Step that pulls from the cache. If you don't have any caching Steps, add the Step right after the Git Clone Step.

  3. In the Carthage command to run input, select the command you wish to run.

    carthage-command.png

    The default value is bootstrap.

    For a list of available commands, run carthage help on a device with Carthage installed.

  4. You can add options to the Carthage call in the Additional options for carthage command input.

    For example, the --platform ios flag ensures that only the iOS version of frameworks will be installed.

  1. Make sure you have a Cartfile included in your project.

  2. Add the carthage Step to your Workflow.

    It should come after any Step that pulls from the cache. If you don't have any caching Steps, add the Step right after the git-clone Step.

    my-workflow:
      steps:
        - activate-ssh-key: {}
        - git-clone: {}
        - restore-carthage-cache: {}
        - carthage:
        - save-carthage-cache: {}
    
  3. In the carthage_command input, select the command you wish to run.

    The default value is bootstrap.

    For a list of available commands, run carthage help on a device with Carthage installed.

    my-workflow:
      steps:
        - activate-ssh-key: {}
        - git-clone: {}
        - restore-carthage-cache: {}
        - carthage:
        - save-carthage-cache: {}
            inputs:
            - carthage_command: bootstrap 
        - save-carthage-cache: {}
    
  4. You can add options to the Carthage call in the carthage_options input.

    For example, the --platform ios flag ensures that only the iOS version of frameworks will be installed.

    my-workflow:
      steps:
        - activate-ssh-key: {}
        - git-clone: {}
        - restore-carthage-cache: {}
        - carthage:
        - save-carthage-cache: {}
            inputs:
            - carthage_command: bootstrap        
            - carthage_options: "--platform ios"          
        - save-carthage-cache: {}
    

Caching Carthage dependencies

With key-based caching, you only need the Restore Carthage cache and the Save Carthage cache Steps to cache your dependencies. These Steps require no configuration as they automatically set up the cache keys and cache paths.

Setting specific cache paths

You don't have to use the default cache paths that the dedicated key-based caching Steps use. If you need to set a specific cache path, you can do so by configuring the Save cache and the Restore cache Steps: Using key-based caching in your builds.

  1. Add the Restore Carthage cache Step to your Workflow

    carthage-command.png

    It should come before the Carthage Step or any Step that needs dependencies to build your app, such as Xcode Archive & Export for iOS.

  2. Add the Save Carthage cache Step to the end of your Workflow.