我正在尝试从 Raywenderlich RxSwift 的第16章:使用RxTest测试运行以下测试:
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()!)
}
}
但是我在模拟器上遇到了这个错误:
架构x86_64的未定义符号: “RxCocoa.DriverSharingStrategy的类型元数据”,引自: TestingTests.TestingViewModel.testColorNameIsRayWenderlichGreenWhenHexStringIs006636() - > ()在TestingViewModel.o中 “RxCocoa.DriverSharingStrategy的协议见证表:RxCocoa中的RxCocoa.SharingStrategyProtocol”,引自: TestingTests.TestingViewModel.testColorNameIsRayWenderlichGreenWhenHexStringIs006636() - > ()在TestingViewModel.o中 “RxCocoa.SharedSequence.asObservable() - > RxSwift.Observable”,引自: TestingTests.TestingViewModel.testColorNameIsRayWenderlichGreenWhenHexStringIs006636() - > ()在TestingViewModel.o中 ld:找不到架构x86_64的符号 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)
这款iPhone 6s:
架构arm64的未定义符号: “RxCocoa.DriverSharingStrategy的类型元数据”,引自: TestingTests.TestingViewModel.testColorNameIsRayWenderlichGreenWhenHexStringIs006636() - > ()在TestingViewModel.o中 “RxCocoa.DriverSharingStrategy的协议见证表:RxCocoa中的RxCocoa.SharingStrategyProtocol”,引自: TestingTests.TestingViewModel.testColorNameIsRayWenderlichGreenWhenHexStringIs006636() - > ()在TestingViewModel.o中 “RxCocoa.SharedSequence.asObservable() - > RxSwift.Observable”,引自: TestingTests.TestingViewModel.testColorNameIsRayWenderlichGreenWhenHexStringIs006636() - > ()在TestingViewModel.o中 ld:找不到架构arm64的符号 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)
Unfortunately, there is no support for this issue in Raywenderlich's forums.