XCode 使用 RxCocoa 部署到模拟器时崩溃

XCode crashes on deploying to Simulator when using RxCocoa

这可能与 Xcode 9 crashes when debugging in swift 重复,但是因为我有一个新帐户,所以我不能在那里发表评论。

我正在使用 XCode 9.1 (9B55) 和 RxSwift / RxCocoa 4.0.0

我正在尝试将我的 TableView 代码迁移到 RxSwift,但每次我的 ViewController 在模拟器或我的设备上加载时,XCode 会与应用程序一起崩溃。

ViewController 设置为我的 UIWindow 的根目录ViewController,因此它是应用程序中加载的第一件事。

这是我的简化版 ViewController:

import UIKit
import RxSwift
import RxCocoa

struct DummyProfile {
    let name: String
    let vid: String
    let userName: String
}

class ProfilesCollectionViewController: UITableViewController {

    private let disposeBag = DisposeBag()

    let profileList = [
            DummyProfile(name: "Test1", vid: "VIDASLKDHASKLDH", userName: "User"),
            DummyProfile(name: "Test1adasidhaskljdhaskljdhaksldhjaskdha", vid: "VIDASLKDHASKLDH", userName: "User"),
            DummyProfile(name: "86435543536543455324", vid: "VIDASLKDHASKLDH", userName: "fluigadshkljdhkldjsfgh ask jgfhaklseth kjahgkds")
        ]

    override func viewDidLoad() {
        super.viewDidLoad()

        tableView.register(ProfileCell.self, forCellReuseIdentifier: "ProfileCell")
        tableView?.alwaysBounceVertical = true
        tableView?.backgroundColor = .lightGray

        Observable.just(profileList).bind(to: tableView.rx.items(cellIdentifier: "ProfileCell", cellType: ProfileCell.self)) { (_, model, cell) in
                cell.viewModel = model
            }.disposed(by: disposeBag)
    }
}

我不认为我的 ProfileCells 的代码很重要,因为它基本上只是一些 UIView 和 AutoLayout 的东西,当我不使用 RxCocoa / RxSwift 时,一切都被确认工作。

这是 XCode 崩溃报告之一。我没有其他事情要继续了:

https://pastebin.com/MPpuGZym

我是不是做错了什么,或者这是我的工具链中某处的错误?

浏览 RxSwift github 问题后,我遇到了这个问题: https://github.com/ReactiveX/RxSwift/issues/1463

虽然不完全相同,但我尝试了建议的解决方案 - 将 Pods' 优化级别从 None 提高到快速。

成功了。

Screenshot of what helped.

我也遇到过类似的情况,但是

tableView.datasource = nil

在 UITableViewController 的 viewDidLoad() 中 成功了