New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any help with debugging? #901

Closed
nmtitov opened this Issue Oct 28, 2013 · 12 comments

Comments

Projects
None yet
5 participants
@nmtitov

nmtitov commented Oct 28, 2013

Hello, looks like strange issues likes me :) (My previous problem was with comparison two tuples, and it seems mysterious, but issue with comparison happened in testing target too)

I keep getting this message when running tests target

2013-10-28 15:58:29.212 Routine[3314:a0b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Value from stream <RACSignal: 0xe476a00> name: +combineLatest: (
    "<RACSignal: 0xe475890> name: [RACAble(<TimelineNightViewController: 0xe474d70>, self.timeline.beginning)] -map:",
    "<RACSignal: 0xe475d80> name: [RACAble(<TimelineNightViewController: 0xe474d70>, self.timeline.ending)] -map:",
    "<RACSignal: 0xe475b60> name:     [[RACAble(<TimelineNightViewController: 0xe474d70>,     self.sunrise)] -map:] -distinctUntilChanged"
) is not a tuple: <RACTuple: 0xe4a2e00> (
    420,
    1620,
    0
)'

Actually I understand that without content it is difficult to understand whats going on, but the last part should be understandable

 is not a tuple: <RACTuple: 0xe4a2e00> (
    420,
    1620,
    0
)'

Well my question is that I don't know whats going on... How can I debug this issue? Any tips would be appreciated.

This is the place where signals and subscriptions are set up. In main target they are working fine.

   RACSignal *timelineBeginningChanged = RACAbleWithStart(self.timeline.beginning);
    RACSignal *sunriseChanged = [RACAbleWithStart(self.sunrise) distinctUntilChanged];

    RACSignal *timelineEndingChanged = RACAbleWithStart(self.timeline.ending);
    RACSignal *sunsetChanged = [RACAbleWithStart(self.sunset) distinctUntilChanged];

    self.beginningNightVisible = [RACSignal
                                  combineLatest:@[timelineBeginningChanged, timelineEndingChanged, sunriseChanged]
                                  reduce:^NSNumber *(NSNumber *tb, NSNumber *te, NSNumber *sunrise) {
                                      NSNumber *visible = @(tb.intValue <= sunrise.intValue && sunrise.intValue <= te.intValue);
                                      return visible;
                                  }];

    self.endingNightVisible = [RACSignal
                               combineLatest:@[timelineBeginningChanged, timelineEndingChanged, sunsetChanged]
                               reduce:^NSNumber *(NSNumber *tb, NSNumber *te, NSNumber *sunset) {
                                   NSNumber *visible = @(tb.intValue <= sunset.intValue && sunset.intValue <= te.intValue);
                                   return visible;
                               }];

Thanks in advance!

@nmtitov

This comment has been minimized.

nmtitov commented Oct 28, 2013

Can you elaborate a bit more?

+combineLatest:reduce: returns signal, not tuple. Reduce accepts block which accepts variable number of arguments, so my code is correct (at least as I see). Honestly I can't see connection between your solution and my issue :-(

The point is that code is working fine when I launch application in usual mode (both simulator and device), but fails when I try to run tests in iOS simulator with this exception.

@babygau

This comment has been minimized.

babygau commented Oct 28, 2013

Editted: I accidently delete my previous comment, here is the update.
The reason would be RACAbleWithStart return a signal that send a Tuple value. You could use -take:1 e.g:
[[RACAbleWithStart(self.sunrise) distinctUntilChanged] take:1]

Because RACCableWithStart is replaced with RACObserve in ReactiveCocoa 2.0 (Simplifier and Safer KVO). You can use it instead: [[RACObserve(self, sunrise) distinctUntilChanged] take:1]

@nmtitov

This comment has been minimized.

nmtitov commented Oct 28, 2013

Thank you, I think that I have to update to make things simpler.
But actually I use 1 version of library (pod 'ReactiveCocoa', '~> 1.9.7'), and code works fine when I run main target. I mean, I don't have to write -take:1, it already works. But when I run tests, code fails with this error. And it says "RACTuple is not a tuple" (is not a tuple: <RACTuple:).

@jspahrsummers

This comment has been minimized.

Member

jspahrsummers commented Oct 28, 2013

@nT9 You probably have ReactiveCocoa linked into your test target in addition to your app, causing duplicate classes. RAC should only be linked into your app.

The reason would be RACAbleWithStart return a signal that send a Tuple value.

@babygau That's not true.

@nmtitov

This comment has been minimized.

nmtitov commented Oct 28, 2013

@jspahrsummers If classes were duplicated linker should swear, shouldn't it? I have runtime error with long stack trace.

@jspahrsummers

This comment has been minimized.

Member

jspahrsummers commented Oct 28, 2013

Unit tests behave differently than libraries. They don't link directly into your application at build time — they're injected dynamically.

@nmtitov

This comment has been minimized.

nmtitov commented Oct 28, 2013

My Podfile contains this line link_with ['Routine', 'RoutineTests'], can it be the reason for this behaviour?

@jspahrsummers

This comment has been minimized.

Member

jspahrsummers commented Oct 28, 2013

I'm not sure, since we don't use CocoaPods ourselves.

@tonyarnold @ashfurrow Can someone more familiar with podfiles chime in here?

@mhupman

This comment has been minimized.

mhupman commented Oct 28, 2013

@nT9 This problem you're seeing isn't related specifically to ReactiveCocoa, but is instead an issue with the way Cocoapods links testing targets. The most obvious manifestation of the problem is that isKindOfClass: doesn't pass for classes that it otherwise should. See CocoaPods/CocoaPods#1411 and CocoaPods/CocoaPods#840.

I didn't have time to dig into the issue when I ran into it, but my temporary solution was just to link everything (including testing libraries like Kiwi) directly into my main target when testing. It sucks, but prevents this issue from cropping up. For example:

platform :ios, '6.1'

pod 'ReactiveCocoa'
pod 'Kiwi/XCTest'
@nmtitov

This comment has been minimized.

nmtitov commented Oct 28, 2013

@mhupman Very interesting, thanks for pointing that. I need to think about organisation of libraries in my project

Well now after @mhupman 's explanation I understand the nature of my issue with RACTuples comparison #801

@tonyarnold

This comment has been minimized.

Contributor

tonyarnold commented Oct 28, 2013

My take would be the same as @jspahrsummers — "RAC should only be linked into your app" — setup a separate CocoaPods target for your Xcode test target, and don't link ReactiveCocoa in to it.

There should be no need to link Kiwi/Specta/RandomTestFrameworkZ into your app directly.

@nmtitov

This comment has been minimized.

nmtitov commented Oct 29, 2013

I ended up with git submodule, tests run great, thanks to everybody. Next time I'll try to set up separate cocoa pods target for tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment