https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
t

tmphey

04/01/2024, 10:10 AM
Hey folks! Is it possible to use a cocoapod dependency in a module in multi-module kmp setup? We have the following setup:
Copy code
- composeApp (shared, gets embed into the iOS project)
-- moduleA
-- moduleB
-- moduleC <- (here I want to use cocoapod dependency)
m

Max

04/02/2024, 7:14 AM
Hey! A bit unrelated but i was trying to use the new CMP resource api in a multi module project (same as you described above). It broke the build and i found out only the composeApp module can access the new resource api for now. So my approach currently: Have an interface (representing the cocoapod dependency) specified in moduleC of what you expect. Use it via koinInject in moduleC. But provide it in the composeApp module via a koin module single<CocoapodLibInterface> {Real()} Works for me
t

tmphey

04/02/2024, 7:35 AM
Yeah, that's the only approach rn I think. I, however, wanted to use types from the dependency also, without wrappers. Seems impossible 😄
m

Max

04/02/2024, 7:41 AM
Even if you get it to work, I would not count on it being reliable enough for production while things in the KMP/CMP world evolve quickly. Was my conclusion at least. I’m gonna have all gradle build magic happen in the composeApp module and work my way around this contraint
👍 1
t

tmphey

04/02/2024, 7:49 AM
I wonder why multi-module features are low-priority, considering the fact that people almost immediately started to build multi-module projects using KMP
m

Max

04/02/2024, 7:52 AM
good point! One of the highest selling points of KMP over Flutter for me is it’s enterprise readieness thanks to gradle and the great multi module capabilities. I guess Jetbrains soon catches up on that. Would waste resources if you build a new feature directly for multi-module envs and then decide to change it altogether. I guess they decided for speed in shipping features instead
(which i can understand)
t

tmphey

04/02/2024, 7:57 AM
Yep, agreed. I hope that once they improve multi-module support in compose gradle plugin, resources and dependencies will automatically work 😄
2 Views