Moussa
12/14/2022, 11:19 PMuli
12/15/2022, 6:15 AMapi
instead of implements
Moussa
12/15/2022, 6:18 AMapi
not implementation
uli
12/15/2022, 7:48 AMapi
?
B/build.gradle:
api(project(“:A”))
api(pod(…
``````Moussa
12/15/2022, 1:42 PMiOSMain by getting {
dependencies {
implementation(pod("")) // this won't work
}
}
How we import pod project is using the following
cocoapods {
pod("POD NAME HERE", "POD VERSION HERE")
}
then it is available on the iOS target
But if you are talking about Module C dependencies, it is all added as api(project(":MODULE NAME"))
kpgalligan
12/15/2022, 2:47 PMIs there is a way not to include all Module B dependencies inside module C?This is pretty confusing. It would be easier to understand if you post the build configs associated. I assume you need Module B’s dependencies in C, or C wouldn’t work, so are you asking how not to export them?
Moussa
12/15/2022, 2:59 PMplugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("com.android.library")
}
kotlin {
android()
jvm()
if (os.isMacOsX) {
ios()
if (System.getProperty("os.arch") != "x86_64") { // M1Chip
iosSimulatorArm64()
}
}
js(IR)
if (os.isMacOsX) {
cocoapods {
this.summary = "ModuleA summary"
this.version = rootProject.version.toString()
this.ios.deploymentTarget = "13.0"
this.osx.deploymentTarget = "12.0"
this.tvos.deploymentTarget = "13.0"
this.watchos.deploymentTarget = "8.0"
framework {
this.baseName = "ModuleA"
}
}
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting
val jvmTest by getting
val androidMain by getting
val androidTest by getting {
dependencies {
implementation("junit:junit:4.13.2")
}
}
val jsMain by getting
val jsTest by getting
if (os.isMacOsX) {
val iosMain by getting
val iosTest by getting
if (System.getProperty("os.arch") != "x86_64") { // M1Chip
val iosSimulatorArm64Main by getting {
this.dependsOn(iosMain)
}
val iosSimulatorArm64Test by getting {
this.dependsOn(iosTest)
}
}
}
}
}
android {
compileSdk = 32
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = 21
targetSdk = 32
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
/**
* Because Software Components will not be created automatically for Maven publishing from
* Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.
* disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new
* publishing DSL.
*/
publishing {
multipleVariants {
withSourcesJar()
withJavadocJar()
allVariants()
}
}
}
Module B
plugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("com.android.library")
}
kotlin {
android()
jvm()
if (os.isMacOsX) {
ios()
if (System.getProperty("os.arch") != "x86_64") { // M1Chip
iosSimulatorArm64()
}
}
js(IR)
if (os.isMacOsX) {
cocoapods {
this.summary = "ModuleB summary"
this.version = rootProject.version.toString()
this.ios.deploymentTarget = "13.0"
this.osx.deploymentTarget = "12.0"
this.tvos.deploymentTarget = "13.0"
this.watchos.deploymentTarget = "8.0"
framework {
this.baseName = "ModuleB"
}
pod("LOCAL POD") {
version = "1.0.0"
source = path(project.file("../iOSLibs/POD FOLDER NAME"))
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
api(project(":ModuleA"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting
val jvmTest by getting
val androidMain by getting
val androidTest by getting {
dependencies {
implementation("junit:junit:4.13.2")
}
}
val jsMain by getting
val jsTest by getting
if (os.isMacOsX) {
val iosMain by getting
val iosTest by getting
if (System.getProperty("os.arch") != "x86_64") { // M1Chip
val iosSimulatorArm64Main by getting {
this.dependsOn(iosMain)
}
val iosSimulatorArm64Test by getting {
this.dependsOn(iosTest)
}
}
}
}
}
android {
compileSdk = 32
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = 21
targetSdk = 32
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
/**
* Because Software Components will not be created automatically for Maven publishing from
* Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.
* disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new
* publishing DSL.
*/
publishing {
multipleVariants {
withSourcesJar()
withJavadocJar()
allVariants()
}
}
}
Module C
plugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("com.android.library")
}
kotlin {
android()
jvm()
if (os.isMacOsX) {
ios()
if (System.getProperty("os.arch") != "x86_64") { // M1Chip
iosSimulatorArm64()
}
}
js(IR)
if (os.isMacOsX) {
cocoapods {
this.summary = "ModuleC summary"
this.version = rootProject.version.toString()
this.ios.deploymentTarget = "13.0"
this.osx.deploymentTarget = "12.0"
this.tvos.deploymentTarget = "13.0"
this.watchos.deploymentTarget = "8.0"
framework {
this.baseName = "ModuleC"
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
api(project(":ModuleB"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting
val jvmTest by getting
val androidMain by getting
val androidTest by getting {
dependencies {
implementation("junit:junit:4.13.2")
}
}
val jsMain by getting
val jsTest by getting
if (os.isMacOsX) {
val iosMain by getting
val iosTest by getting
if (System.getProperty("os.arch") != "x86_64") { // M1Chip
val iosSimulatorArm64Main by getting {
this.dependsOn(iosMain)
}
val iosSimulatorArm64Test by getting {
this.dependsOn(iosTest)
}
}
}
}
}
android {
compileSdk = 32
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = 21
targetSdk = 32
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
/**
* Because Software Components will not be created automatically for Maven publishing from
* Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.
* disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new
* publishing DSL.
*/
publishing {
multipleVariants {
withSourcesJar()
withJavadocJar()
allVariants()
}
}
}
Using the previous build.gradle.kts
scripts
I get Module A imported in Module C and I get the imported pod in Module B inside Module C
ex:
com.moduleA is now available in Module C
And
cocoapods.localPod is now available in Module C
I don’t want that.kpgalligan
12/15/2022, 3:23 PMMoussa
12/15/2022, 4:13 PMkpgalligan
12/15/2022, 8:40 PMMoussa
12/15/2022, 10:24 PMkpgalligan
12/15/2022, 10:28 PMTtC10ModuleAKMMFunctions
and where is it? Do you have a local pod because you’re trying to include some Objc code?Moussa
12/15/2022, 10:32 PMKMMFunctions
is a class name with some functions that I’m using inside KMM. Both the class and functions have the @objc
annotationkpgalligan
12/15/2022, 10:38 PM@objc
, then? I mean, the basic problem is cinterop looks like it imports the headers, but the pod setup isn’t providing the binary. I would guess that’s because it’s a local pod. I’ve never used a local pod as a dependency for cinterop, so I don’t know how that would work. You’ll probably need to add
pod("LOCAL POD") {
version = "1.0.0"
source = path(project.file("../iOSLibs/POD FOLDER NAME"))
}
to any downstream project you want to use it in, but you’ll need to make sure you change the cinterop package name, and you might have linker issues later (“symbols multiply defined”). Building local native source is rather difficult. cinterop just does headers, and as mentioned, I’ve never tried to use a local pod as a dependency.Moussa
12/15/2022, 10:41 PMMoussa
12/15/2022, 10:52 PMpod("ModuleA") {
version = "1.0.0"
source = path(project.file("../iOSLibs/ModuleA"))
}
as you said, it did give me the error “*symbol multiply defined*” so I changed the package name in the Gradle manually to this
pod("ModuleA") {
version = "1.0.0"
packageName = "ModuleA1"
source = path(project.file("../iOSLibs/ModuleA"))
}
This did fix the linker issue.
Should this be considered a bug and an expected behaviour?!kpgalligan
12/15/2022, 11:04 PMShould this be considered a bug and an expected behaviour?!No idea. I doubt they designed Kotlin pod dependencies for local pods like that, but that’s a JetBrains question.
Moussa
12/15/2022, 11:05 PMTejeshwar Amirthy
03/21/2023, 12:03 PMpackageName = "ModuleA1"
for the above to work for you?Moussa
03/21/2023, 12:05 PMTejeshwar Amirthy
03/21/2023, 2:00 PMMoussa
03/22/2023, 10:24 PMTejeshwar Amirthy
03/23/2023, 8:37 PM