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
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 yourPackage.swift file:
Package.swift
Dependencies
The Composable Architecture brings in several dependencies that provide essential functionality:Core dependencies
Core dependencies
- 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
Testing dependencies
Testing dependencies
- swift-custom-dump: Enhanced dump output for tests
- xctest-dynamic-overlay: XCTest support in library code
Effect dependencies
Effect dependencies
- 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:Verify installation
To verify the installation was successful, try creating a simple reducer:Troubleshooting
Build errors about missing types
Build errors about missing types
Make sure you’ve imported
ComposableArchitecture at the top of your file:Deployment target errors
Deployment target errors
Verify your deployment target meets the minimum requirements:
- iOS 16.0+
- macOS 13.0+
- tvOS 16.0+
- watchOS 9.0+
Package resolution failures
Package resolution failures
Try these steps:
- In Xcode, go to File → Packages → Reset Package Caches
- Clean the build folder (Product → Clean Build Folder)
- 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