Andrey Chernoprudov
Andrey Chernoprudov

Reputation: 1359

SPM dependency in different projects

I have iOS workspace of two projects:

Core - is a project with framework. Also it has RxSwift dependency via swift package manager.

App - is an application that has Core.framework as embed dependency and RxSwift as swift package manager dependency.

I get these warnings on app running:

objc[8296]: Class _TtC7RxSwiftP33_AB3B9E8806A71B46FB498A7594F5E0D919AnonymousDisposable is implemented in both /Users/andrey/Library/Developer/Xcode/DerivedData/App-dypyskhwoifkwagjjvtjblqppdnd/Build/Products/Debug-iphonesimulator/Core.framework/Core (0x10e092400) and /Users/andrey/Library/Developer/CoreSimulator/Devices/53D234F9-F917-46BA-B376-F28BA905EE9D/data/Containers/Bundle/Application/D4C69694-8515-44CF-B077-0CB3256D1F84/App.app/App (0x10bf95430). One of the two will be used. Which one is undefined.

But if I try to access MainScheduler.instance that is a static variable I will get EXC_BAD_ACCESS crash with stack:

#0  0x000000010e7d5c07 in swift_checkMetadataState ()
#1  0x000000010e7d9a17 in checkTransitiveCompleteness(swift::TargetMetadata<swift::InProcess> const*)::$_18::operator()(swift::TargetMetadata<swift::InProcess> const*) const ()
#2  0x000000010e7d97ac in bool findAnyTransitiveMetadata<checkTransitiveCompleteness(swift::TargetMetadata<swift::InProcess> const*)::$_18&>(swift::TargetMetadata<swift::InProcess> const*, checkTransitiveCompleteness(swift::TargetMetadata<swift::InProcess> const*)::$_18&) ()
#3  0x000000010e7d96a6 in checkTransitiveCompleteness(swift::TargetMetadata<swift::InProcess> const*) ()
#4  0x000000010e7da278 in swift::MetadataCacheEntryBase<(anonymous namespace)::SingletonMetadataCacheEntry, int>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) ()
#5  0x000000010e7d0078 in swift_getSingletonMetadata ()
#6  0x000000010b3bb9b8 in type metadata accessor for MainScheduler ()
#7  0x000000010af4b1c5 in static RxSchedulers.mainScheduler.getter 

What is the possible way to fix this crash?

Upvotes: 2

Views: 1551

Answers (1)

Andrey Chernoprudov
Andrey Chernoprudov

Reputation: 1359

The problem is that App module has two RxSwift dependencies that conflicts with each other. The first one is a transitive dependency from Core.framework and the second one is inside App module. It causes this crash.

Another sign that you have problems with two same dependencies could be warnings on the application start. Like this one:

objc[8296]: Class _TtC7RxSwiftP33_AB3B9E8806A71B46FB498A7594F5E0D919AnonymousDisposable is implemented in both /Users/andrey/Library/Developer/Xcode/DerivedData/App-dypyskhwoifkwagjjvtjblqppdnd/Build/Products/Debug-iphonesimulator/Core.framework/Core (0x10e092400) and /Users/andrey/Library/Developer/CoreSimulator/Devices/53D234F9-F917-46BA-B376-F28BA905EE9D/data/Containers/Bundle/Application/D4C69694-8515-44CF-B077-0CB3256D1F84/App.app/App (0x10bf95430). One of the two will be used. Which one is undefined.

For this case possible fix is to remove RxSwift dependency from App module. It doesn't broke code because RxSwift is transitive dependency and will be available inside App module.

Upvotes: 3

Related Questions