Skip to main content

Installation

The Composable Architecture can be added to your Xcode project using Swift Package Manager.

Requirements

Before installing, ensure your project meets the minimum platform requirements:
  • iOS 16.0+
  • macOS 13.0+
  • tvOS 16.0+
  • watchOS 9.0+
  • visionOS 1.0+

Swift Package Manager

1

Open package dependencies

In Xcode, navigate to FileAdd Package Dependencies…
2

Enter the repository URL

Enter the following URL into the package repository URL text field:
https://github.com/pointfreeco/swift-composable-architecture
3

Add to your target

Depending on how your project is structured, choose one of the following options:

Single application target

If you have a single application target that needs access to the library, add ComposableArchitecture directly to your application target.

Multiple targets

If you want to use this library from multiple Xcode targets, or mix Xcode targets and SPM targets, you must create a shared framework that depends on ComposableArchitecture and then depend on that framework in all of your targets.
For an example of using TCA with multiple modules, check out the Tic-Tac-Toe demo, which splits features into modules and consumes them using a shared Swift package.

Package.swift

If you’re building a Swift package, you can add the Composable Architecture as a dependency in your Package.swift file:
Package.swift
let package = Package(
  name: "MyPackage",
  platforms: [
    .iOS(.v16),
    .macOS(.v13),
    .tvOS(.v16),
    .watchOS(.v9),
  ],
  dependencies: [
    .package(
      url: "https://github.com/pointfreeco/swift-composable-architecture",
      from: "1.0.0"
    )
  ],
  targets: [
    .target(
      name: "MyTarget",
      dependencies: [
        .product(
          name: "ComposableArchitecture",
          package: "swift-composable-architecture"
        )
      ]
    )
  ]
)

Dependencies

The Composable Architecture brings in several dependencies that provide essential functionality:
  • swift-dependencies: Dependency management system
  • swift-identified-collections: Collection types with stable identity
  • swift-case-paths: Key path abstractions for enum cases
  • swift-perception: Observation tools for iOS <17
  • swift-custom-dump: Enhanced dump output for tests
  • xctest-dynamic-overlay: XCTest support in library code
  • combine-schedulers: Testable Combine schedulers
  • swift-clocks: Testable time-based operations
  • swift-concurrency-extras: Swift concurrency utilities
All dependencies are automatically managed by Swift Package Manager. You don’t need to add them individually.

Import the library

Once installed, import the Composable Architecture in your Swift files:
import ComposableArchitecture

Verify installation

To verify the installation was successful, try creating a simple reducer:
import ComposableArchitecture

@Reducer
struct Feature {
  @ObservableState
  struct State: Equatable {
    var count = 0
  }
  
  enum Action {
    case incrementButtonTapped
  }
  
  var body: some Reducer<State, Action> {
    Reduce { state, action in
      switch action {
      case .incrementButtonTapped:
        state.count += 1
        return .none
      }
    }
  }
}
If this compiles without errors, the installation was successful!

Troubleshooting

Make sure you’ve imported ComposableArchitecture at the top of your file:
import ComposableArchitecture
Verify your deployment target meets the minimum requirements:
  • iOS 16.0+
  • macOS 13.0+
  • tvOS 16.0+
  • watchOS 9.0+
Try these steps:
  1. In Xcode, go to FilePackagesReset Package Caches
  2. Clean the build folder (ProductClean Build Folder)
  3. Restart Xcode

Next steps

Now that you’ve installed the Composable Architecture, you’re ready to build your first feature!

Quick start guide

Follow the quick start guide to build a complete feature with state management, side effects, and tests

Build docs developers (and LLMs) love