ReactiveX / RxSwift

Reactive Programming in Swift
MIT License
24.38k stars 4.17k forks source link

failed to demangle superclass of FlatMapSink from mangled name '*' #2118

Closed SocialTermite closed 4 years ago

SocialTermite commented 4 years ago

Short description of the issue:

When I run my unit tests "failed to demangle superclass of MergeSink from mangled name" error appear with crash. It can be other than MergeSink class.

-all_load tried.

Expected outcome:

Work without crash

What actually happens:

When I start unit tests in my main project RxSwift always crash with errors: failed to demangle superclass of FlatMapSink from mangled name '\^AE\^B'`, name of the class may be different In small test project error also appears.

image

See call stack .

image

Self contained code example that reproduces the issue: (1)

let filledImage = try! api
            .fillImageData(in: testableImage)// Moya request with Single<ImageData>
            .toBlocking()
            .first()

(2) in this case not always error above appear but also crash

func testExpample() {
        let result = "1234"
        let some = Observable<String>.just(result)

        let another = try! rxTest().toBlocking().first()
        XCTAssertEqual(another, result)
    }

    func rxTest() -> Observable<String> {
        return Observable.create { (observer) -> Disposable in
            let result = "1234"
            observer.onNext("1234")
            observer.onCompleted()
            return Disposables.create()
        }
    }

RxSwift/RxCocoa/RxBlocking/RxTest version/commit

RxSwift (5.0.1) RxBlocking (5.0.1)

Platform/Environment

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

Xcode version:

  Version 11.3.1 (11C504)

Installation method: I've tried carthage also.

I have multiple versions of Xcode installed:

Level of RxSwift knowledge:

SocialTermite commented 4 years ago

https://github.com/SocialTermite/Magnificent-Sun - In this repo and commit Another refactoring + unit tests (4d821f8) you can reproduce this error

rynaardb commented 4 years ago

@SocialTermite were you able to find a solution for this or not yet? I'm having the exact same issue as you described.

freak4pc commented 4 years ago

Are you using a Static Library in both these scenarios? Did you attempt linking as dynamic library in CocoaPods ?

vmzhivetyev commented 4 years ago

I have the same issue and the same environment. RxSwift frameworks are built as dynamic libs. Except my error message is failed to demangle superclass of DistinctUntilChangedSink from mangled name '7RxSwift4SinkCyxG'

Any workarounds?

freak4pc commented 4 years ago

Here's a working example with Carthage with both RxTest an RxBlocking. Can you attempt adding your test to it and see how it's working for you. No issues that I can see:

RxCarthage.zip

twink1e commented 4 years ago

@SocialTermite any chance your pods are statically linked while your test targets are dynamically linked? I had similar crash, and it got fixed once I dynamically link the pods.

mohamede1945 commented 4 years ago

My solution to this problem is to only add it to one library. If I added it to 2 libraries or 1 library and the app, I'll get the crash. Also be sure to check transitive dependencies of other SwiftPM packages all libs that uses RxSwift should be linked to only 1 dynamic library.

freak4pc commented 4 years ago

This issue is about Carthage. For SPM specific there is a known bug with transitive dependencies, but they haven't fixed it yet: https://bugs.swift.org/browse/SR-12303

SocialTermite commented 4 years ago

I switched to carthage and it works now.

shunnokw commented 2 years ago

For my case, I have the same error because I didn't include use_frameworks! in my pod file