1

I want to use ReactiveSwift.

  1. Podfile

pod 'ReactiveCocoa', '~> 6.0'

  1. $ pod install

ViewController.swift:

import UIKit
import ReactiveSwift

class ViewController: UIViewController {
    @IBOutlet fileprivate weak var button: UIButton!

    override func viewDidLoad() {
        button.reactive.xxx { ... }
    }
}

I have only this error, so I can run when I comment out button.reactive.xxx { ... }.

Tank you.

shiba1014
  • 69
  • 5
  • How does reactive work? Does it have an _extension_ on `UIButton` that adds the `reactive` member, or are you suposed to use some custom `UIButton` subclass (instead of `UIButton` itself) that **does** have that property? – Nicolas Miari Aug 30 '17 at 09:31
  • By the way, the cocoa pods part seems to be working, otherwise the compler would complain about the `import ReactiveSwift` line. – Nicolas Miari Aug 30 '17 at 09:32
  • I solved this problem when I change `import ReactiveSwift` to `import ReactiveCocoa`! But example code seems to work with `import ReactiveSwift`. Is there any wrong in my project? – shiba1014 Aug 30 '17 at 09:44
  • 1
    So I guess it _is_ and `extension` on `UIButton` that is defined in **ReactiveCocoa** (_not_ ReactiveSwift) – Nicolas Miari Aug 30 '17 at 09:45
  • I see.Thank you! – shiba1014 Aug 30 '17 at 09:52

1 Answers1

1

It's exactly as @NicolasMiari suggested - Reactive Cocoa is split into several parts (since version 5.0 anyway).

Reactive Swift contains the implementation of the core primitives (Signal, SignalProducer, Property, Action) and operators. Notably, this is platform independent.

Reactive Cocoa is built on top of Reactive Swift and adds UIKit and AppKit specific extensions for iOS/macOS via the .reactive property.

MeXx
  • 3,357
  • 24
  • 39