# Managing dependencies with Carthage

[Carthage](https://github.com/Carthage/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**

1. Make sure you have a [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile) included in your project.
1. 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 Repository**](https://github.com/bitrise-steplib/steps-git-clone) Step.
1. In the **Carthage command to run** input, select the command you wish to run.

   ![carthage-command.png](/img/_paligo/uuid-71148b6a-fbf8-6a5f-5423-a5ac2817e866.png)

   The default value is `bootstrap`.

   For a list of available commands, run `carthage help` on a device with Carthage installed.
1. 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.

**Configuration YAML**

1. Make sure you have a [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile) included in your project.
1. 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.

   ```yml
   my-workflow:
     steps:
       - activate-ssh-key: {}
       - git-clone: {}
       - restore-carthage-cache: {}
       - carthage:
       - save-carthage-cache: {}
   ```
1. 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.

   ```yml
   my-workflow:
     steps:
       - activate-ssh-key: {}
       - git-clone: {}
       - restore-carthage-cache: {}
       - carthage:
           inputs:
             - carthage_command: bootstrap
       - save-carthage-cache: {}
   ```
1. 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.

   ```yml
   my-workflow:
     steps:
       - activate-ssh-key: {}
       - git-clone: {}
       - restore-carthage-cache: {}
       - carthage:
           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**](https://github.com/bitrise-steplib/bitrise-step-restore-carthage-cache) and the [**Save Carthage cache**](https://github.com/bitrise-steplib/bitrise-step-save-carthage-cache) Steps to cache your dependencies. These Steps require no configuration as they automatically set up the cache keys and cache paths.

1. Add the [**Restore Carthage cache**](https://github.com/bitrise-steplib/bitrise-step-restore-carthage-cache) Step to your Workflow.

   It should come before the [**Carthage**](https://github.com/bitrise-steplib/steps-carthage) Step or any Step that needs dependencies to build your app, such as [**Xcode Archive & Export for iOS**](https://github.com/bitrise-steplib/steps-xcode-archive).
1. Add the [**Save Carthage cache**](https://github.com/bitrise-steplib/bitrise-step-save-carthage-cache) Step to the end of your Workflow.
