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

jeran

11/03/2020, 6:43 PM
let me give this another shot. has anyone successfully managed to get external cocoapod dependencies working in a kotlin multiplatform project? i feel like i've followed the guide to a t with no luck. https://kotlinlang.slack.com/archives/C3PQML5NU/p1604348567259000
t

Tijl

11/03/2020, 9:07 PM
yes, but not without importing those same dependencies again in the main iOS project
so essentially they are just there to do cinterops in a nice way
j

jeran

11/03/2020, 9:19 PM
oh interesting. so you're suggesting if we add the same dependencies to the host app it might run? I'll give that a shot. unfortunately, that still wouldn't solve the issue that the IDE isn't recognizing the cocoapod dependencies in the shared iOS kotlin files
this is an example of the issue i'm unable to solve:
t

Tijl

11/03/2020, 9:31 PM
that issue I believe is seperate, I guess you are using HMPP?
it’s just the IDE right? gradle works?
j

jeran

11/03/2020, 9:37 PM
running
./gradlew :shared:build
actually does seem to complete successfully. what is HMPP? this is just the base project from using Android Studio with the Kotlin Multiplatform Mobile plugin, and creating a KMM project
t

Tijl

11/03/2020, 9:40 PM
that uses HMPP by default I believe (it’s in gradle.properties), it’s a difference in how you declare iOS targets, together (hmpp) or seperate for arm64 x86
unfortunately I don’t know what exactly you should do in your case, because this has been so unstable I’ve lost track of it
👍 1
j

jeran

11/03/2020, 9:41 PM
ah ok i see. coming from an Android background so i'm unfamiliar with configuring iOS targets.
and got it, well I appreciate the look nonetheless. will keep hacking at it
@Tijl I looked into the HMPP thing you mentioned and came across https://kotlinlang.org/docs/reference/migrating-multiplatform-project-to-14.html using the "select iOS target platform depending on the Xcode environment variables" workaround fixes the IDE errors for me, and also lets me run the app without any changes to the iOS host app. so, with fingers crossed, it seems my issue is solved. interestingly it seems to suggest that you shouldn't have to do this if you have the "hierarchical project structure" enabled, which is what the KMM project template does out of the box. I checked my gradle.properties and indeed it uses:
Copy code
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
so, not entirely sure whats up, but thanks again for pointing me in the right direction.
👍 1
t

Tijl

11/04/2020, 7:43 AM
Jetbrains promised they give the highest priority to “works in gradle but not in the IDE” bugs, glad you got it working