jamieadkins95
03/04/2021, 4:25 PMcontent-data football-data
| |
v v
content-domain football-domain
\ /
\ /
\ /
v v
common
(In reality we have 25+ sdks that sorta follow this dependency structure, and 15+ apps that use them to varying levels)
When converted to KMM modules this works fine on Android. We declare the dependency on content-data and gradle will see the transitive dependency on content-domain and download that too. However on iOS when they bring the content-data framework in, ‘duplicate’ classes get prefixed with the library name. For example content-domain defines a DispatcherProvider
interface that content-data provides an implementation of called DispatcherProviderImpl
.
In the iOS frameworks, DispatcherProvider
gets generated as 2 different protocols:
__attribute__((swift_name("DispatcherProvider")))
@protocol Content_domain_kmmDispatcherProvider
@required
- (Content_domain_kmmKotlinx_coroutines_coreCoroutineDispatcher *)computation __attribute__((swift_name("computation()")));
- (Content_domain_kmmKotlinx_coroutines_coreCoroutineDispatcher *)io __attribute__((swift_name("io()")));
- (Content_domain_kmmKotlinx_coroutines_coreCoroutineDispatcher *)ui __attribute__((swift_name("ui()")));
@end;
and
__attribute__((swift_name("Content_domain_kmmDispatcherProvider")))
@protocol Content_data_kmmContent_domain_kmmDispatcherProvider
@required
- (Content_data_kmmKotlinx_coroutines_coreCoroutineDispatcher *)computation __attribute__((swift_name("computation()")));
- (Content_data_kmmKotlinx_coroutines_coreCoroutineDispatcher *)io __attribute__((swift_name("io()")));
- (Content_data_kmmKotlinx_coroutines_coreCoroutineDispatcher *)ui __attribute__((swift_name("ui()")));
@end;
Anywhere in content-domain that asks for a DispatcherProvider can’t take the implementation provided by content-data because it now implements a different interface/protocol
This issue is also described in this post under subtitle
‘How well do the modules talk to each other?’
https://dev.to/touchlab/multiple-kotlin-frameworks-in-an-application-34e9
Q: Is the multiple sdk setup I’ve described possible with KMM? Is there any way around this, maybe by combining all the source sets into one before generating the iOS framework?russhwolf
03/04/2021, 5:15 PMAnders
03/04/2021, 8:24 PMjamieadkins95
03/05/2021, 10:05 AM