The Composable Architecture is a Swift library developed by Point-Free that provides a structured approach to building applications across all Apple platforms including iOS, macOS, iPadOS, visionOS, tvOS, and watchOS. It works with both SwiftUI and UIKit, offering a consistent methodology for managing state, composing features, handling side effects, and writing tests.
The library addresses core challenges in application development through several key problem domains. State management is handled using simple value types that can be shared across multiple screens, allowing mutations in one screen to be immediately observed elsewhere. Composition enables developers to break down large features into smaller, isolated components that can be extracted into separate modules and reassembled. Side effects are managed in a testable and understandable manner, allowing parts of the application to interact with the outside world predictably. The architecture emphasizes testing at multiple levels, from unit tests of individual features to integration tests of composed features and end-to-end tests that verify how side effects influence the application. All of this is accomplished through a minimal API with few concepts and moving parts.
The core building blocks of the architecture are State, which describes the data a feature needs, Action, which represents all possible events that can occur, Reducer, which evolves state given an action and returns effects, and Store, which is the runtime that executes the reducer and effects while allowing observation of state changes. The library includes extensive examples demonstrating solutions to common and complex problems, including case studies, navigation patterns, higher-order reducers, reusable components, and complete applications like a Tic-Tac-Toe game, Todos app, Voice Memos, and the SyncUps app.
The repository shows strong community engagement and maintenance.
The library was designed through a series of episodes on Point-Free, a video series exploring advanced Swift programming topics. The repository includes comprehensive documentation and a multipart tour of the architecture, making it accessible to developers at various skill levels. The architecture enables developers to write testable code through the TestStore, which allows assertions about how features evolve as actions are sent, including verification of state changes and effect execution. Dependencies can be injected and mocked for testing purposes, allowing deterministic test scenarios even when features interact with external APIs or services.