Xcode 9 crashes when debugging in swift [closed]

2019-07-25 15:30发布

问题:

I'm using the latest RxSwift library for reactive programming and facing a strange problem when debugging my code in Xcode 9.1! I have a collectionView inside tableView header and bind selectedItem of collectionView to ViewModel variable to filter out section items. But when I change selected item of collectionView Xcode crashes and I can't figure out the problem! Is it related to libraries that I use or it's Xcode bug?

回答1:

Since I had a similar problem, maybe my "solution" will help you as well:

After browsing the RxSwift github issues for a bit I came across this issue: https://github.com/ReactiveX/RxSwift/issues/1463

While not exactly the same, I tried the proposed solution - Bumping the Pods' Optimization level from None to Fast.

That did the trick.

Apparently when installed via CocoaPods and when running in Debug mode RxSwift's asserts not only crash the app but also the IDE itself. At least that's what I got from the whole ordeal. Now, while the proposed solution may not be the technically best one (since we're now seemingly ignoring asserts that may actually be important), it got my code working again.

Screenshot of where and what to set in XCode's project settings