Rxswift: BehaviorRelay undefined Symbols for architecture arm64 in unit tests

Created on 27 Feb 2018  路  10Comments  路  Source: ReactiveX/RxSwift

I have upgraded to swift 4.1 from 4.0.

I have changed all the ...value = newValue to ...accept(value:newValue)

I am getting

Undefined symbols for architecture arm64:
"__T07RxCocoa13BehaviorRelayC6acceptyxF", referenced from:
__T023ConnectionManager_Tests15BlowSessionTestC012testCanStartE0yyF in BlowSessionTest.o
__T023ConnectionManager_Tests07CommandC0C04testaB25GetIntFromDeviceIsCorrectyyFyycfU_ in CommandTests.o
__T023ConnectionManager_Tests07CommandC0C04testaB28GetStringFromDeviceIsCorrectyyFyycfU_ in CommandTests.o
"__T07RxCocoa13BehaviorRelayC5valuexfg", referenced from:
__T023ConnectionManager_Tests15BlowSessionTestC012testCanStartE0yyF in BlowSessionTest.o
__T023ConnectionManager_Tests0aB4TestC31testIsSyncingChangesWhenStoppedyyFSbyKXKfu_ in ConnectionManagerTest.o
__T023ConnectionManager_Tests0aB4TestC24testIsSyncingWhenStartedyyFSbyKXKfu_ in ConnectionManagerTest.o
"__T07RxCocoa13BehaviorRelayC12asObservable0A5Swift0F0CyxGyF", referenced from:
__T023ConnectionManager_Tests15BlowSessionTestC023testAddingFiveCompletedd16CorrectlyChangesE0yyF in BlowSessionTest.o
__T023ConnectionManager_Tests15BlowSessionTestC027testAddingMultipleCompletedd16CorrectlyChangesE0yyF in BlowSessionTest.o
__T023ConnectionManager_Tests15BlowSessionTestC031testCompletionOnlyFiresOnceWhenE11IsCompletedyyF in BlowSessionTest.o
__T023ConnectionManager_Tests15BlowSessionTestC43testAdding75GoodBlowsGetsCorrectCompletionsyyF in BlowSessionTest.o
__T023ConnectionManager_Tests15BlowSessionTestC043testAdding75GoodBlowsGetsCorrectCompletionsF9ScheduleryyF in BlowSessionTest.o
__T023ConnectionManager_Tests15BlowSessionTestC14test321sessionyyF in BlowSessionTest.o
__T023ConnectionManager_Tests15BlowSessionTestC027testAddingMultipleCompletedd16CorrectlyChangesE9GotFromDbyyF in BlowSessionTest.o

errors in all my unit test

RxSwift/RxCocoa/RxBlocking/RxTest version/commit

4.10

Platform/Environment

  • [1 ] iOS
  • [ ] macOS
  • [ ] tvOS
  • [ ] watchOS
  • [ ] playgrounds

How easy is to reproduce? (chances of successful reproduce after running the self contained code)

  • [1 ] easy, 100% repro
  • [ ] sometimes, 10%-100%
  • [ ] hard, 2% - 10%
  • [ ] extremely hard, %0 - 2%

Xcode version:

Version 9.2 (9C40b)

Installation method:

  • [1 ] CocoaPods
  • [ ] Carthage
  • [ ] Git submodules

I have multiple versions of Xcode installed:
(so we can know if this is a potential cause of your issue)

  • [ ] yes (which ones)
  • [ 1] no

Level of RxSwift knowledge:
(this is so we can understand your level of knowledge
and formulate the response in an appropriate manner)

  • [ ] just starting
  • [ ] I have a small code base
  • [1 ] I have a significant code base

Most helpful comment

@markGilchristBookingBug I was having a similar issue. Adding import RxCocoa and import RxSwift to my unit test file solved the linker build error.

All 10 comments

Hi @markGilchristBookingBug ,

did you try cleaning your derived data directory? Why do you think this is a problem with the project? As far as I can tell unit tests are passing.

hi @kzaher,

I have deleted the derived data and cleaned the project and I still have the problem

I have also deleted the projected, then cloned it fresh from git the run pod update and I still have the problem

I am getting the linker error where ever I reference BehaviorRelay.accept in my unit tests. This doesn't seam to be a problem in my target code.

I got this errors when I refactored all my Variables -> BehaviorRelay

please let me know if I can help further and thank you for taking the time to look at this issue

m

@markGilchristBookingBug What are the steps for me to reproduce that behavior in a completely new project?

@kzaher

I have created a new project with the problem in
1) create new project adding rxSwift and RxCocoa
2) in the project create a struct

import Foundation
import RxCocoa

struct Stream {
    static let flow = BehaviorRelay(value: 1)
}

3) then go to the unit tests and write a test like

func testStream() {
      // arrange
      Stream.flow.accept(2)
      XCTFail()
  }

4) this will recreate the error.
5) if you go to the Stream.swift as and check the test as a target membership the error will disappear. I cant see why it is not imported when using the @testable import .... I hope this helps
mark

@markGilchristBookingBug I was having a similar issue. Adding import RxCocoa and import RxSwift to my unit test file solved the linker build error.

@markGilchristBookingBug does @ebaker355 solution fixes your issue?

@kzaher @ebaker355 Thanks guys that does fix the problem! my test are running again

I did importing RxSwift and RxCocoa but I still get the linker error

Had same problem, but managed.
my steps:
installed pod RxCocoa. (added { pod 'RxCocoa', '~> 4.0' } to podfile)
imported RxCocoa in playground file code.
cleaned cache(cmd+shift+k)
run(still failed like agiokas mentioned in previous comment).
cleaned+build project.
build was succeeded and run after.

I had the same problem because I tried to call BehaviourRelay from the new Target (and I forgot to add the RxSwift and RxCocoa pods for it)
Everything was fixed when I added RxSwift and RxCocoa to the Podfile in new target.

```
def rx_pods
pod 'RxSwift'
pod 'RxCocoa'
end

target 'MyNewTarget' do
rx_pods
default_pods
end```

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kzaher picture kzaher  路  3Comments

trant picture trant  路  3Comments

RafaelPlantard picture RafaelPlantard  路  3Comments

delebedev picture delebedev  路  3Comments

Z-JaDe picture Z-JaDe  路  3Comments