Hi! I have question about Cocoa Pods dependencies ...
# multiplatform
p
Hi! I have question about Cocoa Pods dependencies in KMM. Suppose there are two multi-platform modules “lib” and “shared” “shared” depends on “lib” Both modules require AFNetworking framework. What is the proper way to add CocoaPods dependency on AFNetworking? Should I add this fragment to both modules or just to module “lib”? pod(“AFNetworking”) { version = “~> 4.0.1” }
👀 1
k
I’m not sure what is a proper way, but adding it to both modules will let you compile and use your framework in the iOS app. When you add only to “lib” won’t work if I remember correctly
v
cocoapods plugin does not support transitive dependencies, so adding dependency to one module will not work
p
Thank you so much, Kamil and Viacheslav! I’ve added the dependency to both modules. It works so far. The only issue I’ve noticed is a highlighting error in “share” module.
Any workaround for these highlighting errors?
The highlighting error show up in “share” code after I’ve added
Copy code
pod("AFNetworking") {
    version = "~> 4.0.1"
}
to build.gradle.kts of “lib” module
k
Do you have
kotlin.mpp.enableGranularSourceSetsMetadata=true
in your
gradle.properties
file?
p
Yes. I’m testing on default new project, created by Android Studio. This is my gradle.properties.
Copy code
#Gradle
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"

#Kotlin
kotlin.code.style=official

#Android
android.useAndroidX=true

#MPP
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
kotlin.mpp.enableCInteropCommonization=true
k
Then unfortunately I don’t know. I would try
invalidate caches and restart
option or try to sync project once again
p
It seems to me, that this functionality is not supported yet. I wonder if @Vyacheslav Karpukhin [JB] to confirm my guess. I’ve tried to sync gradle files. Doesn’t help, unfortunately. Anyway, thanks, Kamil.
v
@Pavel Repkin Hi, you probably meant @Viacheslav Kormushkin, or am I missing something? 🙂
p
Ahhhh, my bad! Vyacheslav, I’m so sorry!
🙂 2
v
Cocoapods integration works well with single module only and no guarantee that it will work with multiple modules, however I tried to setup a project with the structure you described and I did not see the issue you have. Could you please share your project?
p
Viacheslav, thank you for confirming that only a single module works fine. I created the problem project one more time from scratch. This time the highlighting is broken in the code of “shared” project.
I have uploaded the project to github