Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing rx throws error on scheduler init

Tags:

ios

swift

Unit test terminates if I write var scheduler = TestScheduler(initialClock: 0)

my imports

import XCTest
import RxTest

with error message

failed to demangle superclass of TestScheduler from mangled name '7RxSwift20VirtualTimeSchedulerCy0A4Test0fecD9ConverterVG'

pod versions

pod 'RxBlocking', '~> 5'
pod 'RxTest', '~> 5'
like image 314
LeTadas Avatar asked Jul 02 '26 02:07

LeTadas


1 Answers

This is a bug of the Cocoapods + XCode 10.2 platform.

Statement from XCode 10.2 RC notes about known issues:

Linking against a static Swift library might create a binary with missing 
type metadata because the object files that define the metadata inside the 
static archive are mistakenly considered unused. (47598583)

This can manifest as a Swift runtime error with a message such as:
“failed to demangle superclass of MyClass from mangled name ‘<mangled name>’”.

Workaround: If you can rebuild the static library, try building it with whole module 
optimization enabled. 
Otherwise, add -all_load to the linker flags in the client binary to 
ensure all object files are linked into it.

This thread and this solution should help you get rid of it.

like image 117
Václav Avatar answered Jul 03 '26 16:07

Václav



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!