Guide · Open source
How to use ReactiveCocoa: install, bind UI and observe values
Updated · written with AI from the project's own documentation and checked against our catalogue data
ReactiveCocoa is an MIT-licensed Swift library that adds reactive extensions to Apple's Cocoa frameworks, built on top of ReactiveSwift. It lets you treat UI elements, user actions and object changes as streams of values. This guide shows how to add it to a project, the main binding patterns, and where to find more help after you finish.
Quick start
- 1Check prerequisites. Confirm you have Xcode and that your target platforms fall within the supported versions listed in the README.
- 2Add ReactiveCocoa with your package manager. Add the Swift Package Manager dependency, Podfile line or Cartfile line shown in the install section.
- 3Import the frameworks. Import ReactiveSwift and ReactiveCocoa in the files where you bind values, since the <~ operator comes from ReactiveSwift.
- 4Bind a property to a control. Use nameLabel.reactive.text <~ person.name style bindings to connect model values to UI.
- 5Handle user input as signals. Subscribe to control signals such as isOnValues or continuousTextValues to react to changes.
- 6Observe key paths or method calls. Use producer(forKeyPath:) or reactive.trigger(for:) when you need KVO or Objective-C interception.
What do you need before installing ReactiveCocoa?
ReactiveCocoa supports macOS 10.9+, iOS 8.0+, watchOS 2.0+, and tvOS 9.0+. It depends on ReactiveSwift, so you must add that framework alongside it. The project is written in Swift, and the README lists Xcode with Swift Package Manager, CocoaPods or Carthage as the ways to pull it in.
- Xcode
- One of: Swift Package Manager, CocoaPods or Carthage
- ReactiveSwift, installed alongside ReactiveCocoa
How do you install ReactiveCocoa with Swift Package Manager, CocoaPods or Carthage?
Pick the package manager your project already uses. For Swift Package Manager, add ReactiveCocoa as a dependency in Package.swift. For CocoaPods, add a line to your Podfile. For Carthage, add a line to your Cartfile.
With Carthage, make sure ReactiveCocoa.framework and ReactiveSwift.framework are in the Linked Frameworks and Libraries section of your target and included in your Carthage framework copying build phase.
The README also describes a Git submodule approach, which involves dragging in ReactiveCocoa.xcodeproj and the ReactiveSwift project, then adding both frameworks to Embedded Binaries.
- Swift Package Manager: .package(url: "https://github.com/ReactiveCocoa/ReactiveCocoa.git", branch: "master")
- CocoaPods in Podfile: pod 'ReactiveCocoa', '~> 10.1'
- Carthage in Cartfile: github "ReactiveCocoa/ReactiveCocoa" ~> 10.1
.package(url: "https://github.com/ReactiveCocoa/ReactiveCocoa.git", branch: "master")How do you bind a value to a UI control?
UI components expose BindingTargets, which accept bindings from any stream of values through the <~ operator. You will need to import ReactiveSwift as well to use that operator.
The README's example binds a person's name property to a label's text.
nameLabel.reactive.text <~ person.nameHow do you respond to user interactions and control events?
Interactive controls expose Signals for control events and for changes in their value caused by user input. A selected set of controls also offers a binding API for Actions.
The README shows a toggle feeding a preference, a live character count from a text field, and a button wired to a view model command.
preferences.allowsCookies <~ toggle.reactive.isOnValues
textField.reactive.continuousTextValues.map { $0.characters.count }
button.reactive.pressed = CocoaAction(viewModel.commit)How do you observe Objective-C method calls and object lifetime?
ReactiveCocoa can create signals by intercepting Objective-C objects, for example when a method is called or when an object is deinitialized. The README gives an example that fires after each viewWillAppear(_:) call and another that observes when an object's lifetime ends.
let appearing = viewController.reactive.trigger(for: #selector(UIViewController.viewWillAppear(_:)))
object.reactive.lifetime.ended.observeCompleted(doCleanup)How do you observe key paths?
Key-value observations are exposed as SignalProducers and DynamicProperties, so they can be composed with other ReactiveSwift operators. The producer sends the current value and then later changes, and can be stopped when the lifetime of self ends. A DynamicProperty holds a weak reference to the object it wraps.
let producer = object.reactive.producer(forKeyPath: #keyPath(key))
.take(during: self.reactive.lifetime)
let property = DynamicProperty<String>(object: person, keyPath: #keyPath(person.name))Where can you get help?
The README points to the in-code documentation and release notes for more detail. For questions, it recommends searching GitHub issues and Stack Overflow, and filing an issue if you cannot find a solution in the archives. If you need the Objective-C API, the README points to the separate ReactiveObjC project, and for ReactiveSwift primitives it links to that project's framework overview.
- GitHub issues: github.com/ReactiveCocoa/ReactiveCocoa/issues
- Stack Overflow tag: reactive-cocoa
- Migrating from RAC 4.x: see CHANGELOG.md
What people use it for
- Keeping a UILabel's text in sync with a model property using a binding
- Updating a preference value whenever a UISwitch-style toggle changes
- Showing a live character count while a user types in a text field
- Running cleanup code when an object's lifetime ends
- Triggering logic each time an Objective-C method such as viewWillAppear(_:) is called
Frequently asked questions
Is ReactiveCocoa free to use?
ReactiveCocoa is released under the MIT licence, as stated in its repository. You can use it in projects according to the terms of that licence.
What does ReactiveCocoa require?
It requires ReactiveSwift alongside it, plus Xcode and one of Swift Package Manager, CocoaPods or Carthage. The README lists supported platforms as macOS 10.9+, iOS 8.0+, watchOS 2.0+, and tvOS 9.0+.
How do I install ReactiveCocoa with CocoaPods?
Add pod 'ReactiveCocoa', '~> 10.1' to your Podfile and install as usual. The README uses this version constraint in its example.
Can I use ReactiveCocoa from Objective-C?
The README says the Objective-C API is not in this project and points to the separate ReactiveObjC project for that.
Is ReactiveCocoa a good alternative to Combine or RxSwift?
ReactiveCocoa is one of several reactive options, and the comparable projects are ReactiveObjC, Combine and RxSwift. It is a good fit if you already use ReactiveSwift; otherwise the source does not compare them in detail, so evaluate each against your needs.
Why is my build failing after adding ReactiveCocoa with Carthage?
The README says to make sure ReactiveCocoa.framework and ReactiveSwift.framework are linked in Linked Frameworks and Libraries and included in your Carthage copying build phase. Missing either step can cause build problems. If you still have trouble, search the GitHub issues or Stack Overflow.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
ReactiveCocoa suits iOS or macOS developers who already use ReactiveSwift, or who maintain an existing ReactiveCocoa codebase and want declarative bindings between models and controls. It is a poor choice for a new project that needs minimal dependencies, for Objective-C-only work, or for beginners who are not yet comfortable with reactive programming.
Install options & downloads