Short description of the issue:
Run Unit test crash on methodizing class 'RxSwift.MainScheduler'
Expected outcome:
run unit test successfully
What actually happens:
Run Unit test crash on methodizing class 'RxSwift.MainScheduler'
crash log and backtrace:
objc[6727]: CLASS: realizing class 'RxSwift.MainScheduler' 0x124779ea8 0x1245f3750 #0 (swift)
objc[6727]: CLASS: realizing class 'RxSwift.SerialDispatchQueueScheduler' 0x12477a6c8 0x1245f5278 #0 (swift)
objc[6727]: CLASS: realizing class 'RxSwift.SerialDispatchQueueScheduler' (meta) 0x12477a690 0x1245f5208 #0
objc[6727]: CLASS: methodizing class 'RxSwift.SerialDispatchQueueScheduler' (meta)
objc[6727]: CLASS: methodizing class 'RxSwift.SerialDispatchQueueScheduler'
objc[6727]: CLASS: realizing class 'RxSwift.MainScheduler' (meta) 0x124779e70 0x1245f36c0 #0
objc[6727]: CLASS: methodizing class 'RxSwift.MainScheduler' (meta)
objc[6727]: CLASS: methodizing class 'RxSwift.MainScheduler'
(lldb) BT
error: 'BT' is not a valid command.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x9)
frame #0: 0x000000022a306f9c libswiftCore.dylib`swift_checkMetadataState + 380
frame #1: 0x000000022a30a708 libswiftCore.dylib`bool findAnyTransitiveMetadata<checkTransitiveCompleteness(swift::TargetMetadata<swift::InProcess> const*)::$_14&>(swift::TargetMetadata<swift::InProcess> const*, checkTransitiveCompleteness(swift::TargetMetadata<swift::InProcess> const*)::$_14&) + 120
frame #2: 0x000000022a30a600 libswiftCore.dylib`checkTransitiveCompleteness(swift::TargetMetadata<swift::InProcess> const*) + 100
frame #3: 0x000000022a30b1f0 libswiftCore.dylib`swift::MetadataCacheEntryBase<(anonymous namespace)::SingletonMetadataCacheEntry, int>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) + 264
frame #4: 0x000000022a301820 libswiftCore.dylib`swift_getSingletonMetadata + 636
frame #5: 0x00000001232e8d28 MyAppTests`type metadata accessor for MainScheduler at <compiler-generated>:0
frame #6: 0x00000001232ea538 MyAppTests`ObjC metadata update function for MainScheduler at <compiler-generated>:0
frame #7: 0x00000001fb7d9404 libobjc.A.dylib`realizeClassMaybeSwiftMaybeRelock(objc_class*, mutex_tt<false>&, bool) + 248
frame #8: 0x00000001fb7cd958 libobjc.A.dylib`realizeAllClasses() + 100
frame #9: 0x00000001fb7d08d8 libobjc.A.dylib`objc_copyClassList + 120
frame #10: 0x000000011c290550 XCTest`+[XCTestCase(RuntimeUtilities) _allSubclasses] + 76
frame #11: 0x000000011c290690 XCTest`+[XCTestCase(RuntimeUtilities) allSubclasses] + 24
frame #12: 0x000000011c2262d4 XCTest`+[XCTestSuite _suiteForBundleCache] + 216
frame #13: 0x000000011c228718 XCTest`-[XCTestSuite _initWithTestConfiguration:] + 508
frame #14: 0x000000011c228f70 XCTest`+[XCTestSuite testSuiteForTestConfiguration:] + 56
frame #15: 0x000000011c2a7814 XCTest`__44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke + 104
frame #16: 0x000000011c2a795c XCTest`__44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke.84 + 108
frame #17: 0x000000011c240b10 XCTest`-[XCTestObservationCenter _observeTestExecutionForBlock:] + 512
frame #18: 0x000000011c2a7620 XCTest`-[XCTTestRunSession runTestsAndReturnError:] + 596
frame #19: 0x000000011c20bdfc XCTest`-[XCTestDriver runTestsAndReturnError:] + 428
frame #20: 0x000000011c292148 XCTest`_XCTestMain + 2400
frame #21: 0x000000011bb657d4 libXCTestBundleInject.dylib`__RunTests_block_invoke_2 + 16
frame #22: 0x00000001fc57e10c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
frame #23: 0x00000001fc57da10 CoreFoundation`__CFRunLoopDoBlocks + 272
frame #24: 0x00000001fc578a74 CoreFoundation`__CFRunLoopRun + 1024
frame #25: 0x00000001fc578354 CoreFoundation`CFRunLoopRunSpecific + 436
frame #26: 0x00000001fe77879c GraphicsServices`GSEventRunModal + 104
frame #27: 0x0000000228b63b68 UIKitCore`UIApplicationMain + 212
* frame #28: 0x000000010435b3f0 MyApp`main at AppDelegate.swift:14
RxSwift/RxCocoa/RxBlocking/RxTest version/commit
_version or commit here_
Platform/Environment
How easy is to reproduce? (chances of successful reproduce after running the self contained code)
Xcode version:
Xcode 11.3 beta(11C24b)
Installation method:
I have multiple versions of Xcode installed:
(so we can know if this is a potential cause of your issue)
Level of RxSwift knowledge:
(this is so we can understand your level of knowledge
and formulate the response in an appropriate manner)
Please provide a reproducible code sample/project @bupojung
Please provide a reproducible code sample/project @bupojung
@freak4pc this project can reproduce the problem
TestTargetCrash.zip
realizingclass.log
a complete log of realizing class when running unit test
I'm having the same issue. Is there any word on how to fix this? For reference, I am on Xcode Version 11.3.1 (11C504).
Just run into this issue myself, any information would be a great help. Thanks!
EDIT: I fixed my issue following this solution: https://stackoverflow.com/questions/33233419/class-x-is-implemented-in-both-when-executing-unit-tests-in-a-project-that-use
Just wanted to add that the solution that @JamesRoome gave worked for me!
@bupojung This isn't an issue with RxSwift. As mentioned above, you'd want to have a test target as a sub-target of your main target. That way, you don't have to define RxSwift twice but can simply inherit.
e.g.
target 'App' do
use_frameworks!
pod 'RxSwift'
target 'AppTests' do
inherit! :search_paths
pod 'RxTest'
end
end
etc...