Search code examples
iosswiftrx-swiftrx-cocoarxtest

RxTest: Undefined symbols for architecture x86_64 and arm64


I am trying to run the following test from Chapter 16: Testing with RxTest of Raywenderlich RxSwift book:

import XCTest
import RxSwift
import RxTest
@testable import Testing

class TestingViewModel : XCTestCase {

var viewModel: ViewModel!
var scheduler: ConcurrentDispatchQueueScheduler!

override func setUp() {
super.setUp()

viewModel = ViewModel()
scheduler = ConcurrentDispatchQueueScheduler(qos: .default)
}

func testColorNameIsRayWenderlichGreenWhenHexStringIs006636() {

// 1
let colorNameObservable = viewModel.colorName.asObservable().subscribeOn(scheduler)

// 2
viewModel.hexString.value = "#006636"

// 3
XCTAssertEqual("rayWenderlichGreen", try! colorNameObservable.toBlocking().first()!)
 }
}

But I get this error on the simulator:

Undefined symbols for architecture x86_64: "type metadata for RxCocoa.DriverSharingStrategy", referenced from: TestingTests.TestingViewModel.testColorNameIsRayWenderlichGreenWhenHexStringIs006636() -> () in TestingViewModel.o "protocol witness table for RxCocoa.DriverSharingStrategy : RxCocoa.SharingStrategyProtocol in RxCocoa", referenced from: TestingTests.TestingViewModel.testColorNameIsRayWenderlichGreenWhenHexStringIs006636() -> () in TestingViewModel.o "RxCocoa.SharedSequence.asObservable() -> RxSwift.Observable", referenced from: TestingTests.TestingViewModel.testColorNameIsRayWenderlichGreenWhenHexStringIs006636() -> () in TestingViewModel.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

And This one on iPhone 6s:

Undefined symbols for architecture arm64: "type metadata for RxCocoa.DriverSharingStrategy", referenced from: TestingTests.TestingViewModel.testColorNameIsRayWenderlichGreenWhenHexStringIs006636() -> () in TestingViewModel.o "protocol witness table for RxCocoa.DriverSharingStrategy : RxCocoa.SharingStrategyProtocol in RxCocoa", referenced from: TestingTests.TestingViewModel.testColorNameIsRayWenderlichGreenWhenHexStringIs006636() -> () in TestingViewModel.o "RxCocoa.SharedSequence.asObservable() -> RxSwift.Observable", referenced from: TestingTests.TestingViewModel.testColorNameIsRayWenderlichGreenWhenHexStringIs006636() -> () in TestingViewModel.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Unfortunately, there is no support for this issue in Raywenderlich's forums.


Solution

  • After a lot of searches, As somebody suggests here for another similar issue I found that this error will be solved by importing RxCocoa.