How can I fix my install of ReactiveCocoa (with Co

2019-07-03 05:02发布

问题:

Newbie here, trying to install ReactiveCocoa 2.2.4 with CocoaPods into a project and running into errors at runtime. I have used this podspec on github. Here's my code --

MainViewController.m @interface has:

@property (strong, nonatomic) NSString *testString;

MainViewController.m viewDidLoad() has:

self.testString = @"hello";
[RACObserve(self, testString) subscribeNext:^(NSString *newString) {
    NSLog(@"%@", newString);
}];
self.testString = @"yellow";

This is the runtime error I get, where it looks as though "self" is getting the selector sent to it instead of "testString":

exception 'NSInvalidArgumentException', reason: '-[MainViewController rac_valuesForKeyPath:observer:]: unrecognized selector sent to instance

FWIW, I have been able to successfully install ReactiveCocoa via CocoaPods twice in two fresh xcode projects following this youtube vid -- both with and without the podspec i'm trying to use in my other project.

More info about my setup:

  • Xcode 5
  • In Target: General: Linked Libraries and Frameworks: libPods.a (in black -- weirdly, in the new projects where ReactiveCocoa works, this is red)
  • In Target: Build Settings: Other Linker Flags: -ObjC and -all_load (even though my understanding is that adding these is no longer necessary. also, whether I have them or not, i still get the same result).
  • In Target: Build Settings: Header Search Paths: (all non-recursive, all added by CocoaPods): "${PODS_ROOT}/Headers", "${PODS_ROOT}/Headers/ReactiveCocoa", "${PODS_ROOT}/Headers/ReactiveCocoa/ReactiveCocoa"
  • In Target: Build Phases: Target Dependencies: nada (do I need something here?)
  • In Target: Build Phases: Link Binary With Libraries: : libPods.a (in black -- weirdly, in the new projects where ReactiveCocoa works, this is red)

Thanks for any help!