Hossein Amini
11/21/2022, 6:21 PMBig Chungus
11/21/2022, 6:56 PMayodele
11/21/2022, 8:28 PMyou can only have one kotlin native build for objc/swift integration, but that's easy to circumvent via wrapper module that pools in all required kmp dependencies
Big Chungus
11/21/2022, 8:29 PMBig Chungus
11/21/2022, 8:30 PMayodele
11/21/2022, 8:38 PMshared module has dependency on domain and data module will that work??Big Chungus
11/21/2022, 8:56 PMHossein Amini
11/24/2022, 2:21 PMval commonMain by getting {
dependencies {
api(project(":data"))
}
}
But in iOS side it cannot recognize the data module.
There is no issue in Android.
What is wrong with this implementation?Big Chungus
11/24/2022, 2:22 PMdata module declare ios targets too?
Did you try building it to see if it's just an IDE issue?
Did you try syncing the project in IDE?Hossein Amini
11/24/2022, 2:30 PMdata module declares iOS targets (It is just a regular KMM module)
I tried to clean and build the project but the issue is still there.Big Chungus
11/24/2022, 2:31 PMBig Chungus
11/24/2022, 2:33 PMHossein Amini
11/24/2022, 2:35 PMdata module. In Android when I use this class there is no problem and the project builds successfully but in iOS it says it cannot find that class. There is no issue in gradleayodele
11/24/2022, 2:36 PMdata module under the shared moduleBig Chungus
11/24/2022, 2:37 PMBig Chungus
11/24/2022, 2:38 PMHossein Amini
11/24/2022, 2:40 PMBig Chungus
11/24/2022, 2:41 PMHossein Amini
11/24/2022, 2:42 PMBig Chungus
11/24/2022, 2:42 PMBig Chungus
11/24/2022, 2:43 PMHossein Amini
11/24/2022, 2:46 PMHossein Amini
11/24/2022, 2:47 PMdata
kotlin {
android()
iosX64()
iosArm64()
iosSimulatorArm64()
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
version = "1.0"
ios.deploymentTarget = "14.1"
framework {
baseName = "data"
}
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting
val androidTest by getting
val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}
val iosX64Test by getting
val iosArm64Test by getting
val iosSimulatorArm64Test by getting
val iosTest by creating {
dependsOn(commonTest)
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
}
}
And this one is for shared
kotlin {
android()
iosX64()
iosArm64()
iosSimulatorArm64()
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
version = "1.0"
ios.deploymentTarget = "14.1"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "shared"
}
}
sourceSets {
val commonMain by getting {
dependencies {
api(project(":data"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting
val androidTest by getting
val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}
val iosX64Test by getting
val iosArm64Test by getting
val iosSimulatorArm64Test by getting
val iosTest by creating {
dependsOn(commonTest)
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
}
}Big Chungus
11/24/2022, 2:49 PMdata module (you're not exporting it directly, remember)Hossein Amini
11/24/2022, 2:54 PMBig Chungus
11/24/2022, 2:54 PMBig Chungus
11/24/2022, 2:54 PMexport(project(":anotherKMMModule")) bitBig Chungus
11/24/2022, 2:55 PMexport(project(":data")) to your kotlin.cocoapods.framework {} in shared module.Hossein Amini
11/24/2022, 2:58 PMexport(project(":anotherKMMModule")) ?Big Chungus
11/24/2022, 3:01 PMdata module when it builds shared module. In other words, data is available to shared kotlin code only, but not objc/swift. Think of it as gradle's implementation dependency. Once you export it to cocoapods, it makes it transitive to objc layer like gradle's api does for android.Big Chungus
11/24/2022, 3:01 PMBig Chungus
11/24/2022, 3:04 PMBig Chungus
11/24/2022, 3:10 PMtransitiveExport = true flag. I wonder if that would just export all kotlin dependencies implicitly as opposed to you having to declare each explicitly. Would you mind replacing export statement from earlier with transitiveExport = true and let me know if it still works on ios side?Hossein Amini
11/24/2022, 3:17 PMBig Chungus
11/24/2022, 3:26 PMHossein Amini
11/24/2022, 3:28 PMayodele
11/25/2022, 5:22 PMdata domain presentation.
You can avoid exporting the data and domain layers if you limit their access to the shared module.
This will help you not ending up with bloated framework.