nguyen tuan
01/02/2024, 1:43 AMplugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("com.android.library")
}
kotlin {
android()
iosX64()
iosArm64()
iosSimulatorArm64()
js(IR) {
nodejs()
binaries.library()
}
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
version = "1.0"
ios.deploymentTarget = "14.1"
framework {
baseName = "kotlinmultiplatformsharedmodule"
}
}
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 {
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 {
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
val mobileMain by creating {
dependsOn(commonMain)
androidMain.dependsOn(this)
iosMain.dependsOn(this)
}
val mobileTest by creating {
dependsOn(commonTest)
androidTest.dependsOn(this)
iosTest.dependsOn(this)
}
val jsMain by getting
val jsTest by getting
}
}
tasks.register("nodeJsSetup") {
group = "setup"
description = "Setup Node.js for Kotlin Multiplatform project"
doLast {
// Perform necessary Node.js setup steps here
exec {
commandLine("npm", "install") // For npm
// Or commandLine("yarn", "install") // For Yarn
}
}
}
tasks.named("compileKotlinJs").configure {
dependsOn("nodeJsSetup")
}
android {
namespace = "com.example.kotlinmultiplatformsharedmodule"
compileSdk = 32
defaultConfig {
minSdk = 21
targetSdk = 32
}
}
tasks.clean {
doLast {
tasks.register<Delete>("clean") {
delete(rootProject.buildDir)
}
}
}
Taush Sampley
01/02/2024, 4:33 AMnguyen tuan
01/02/2024, 6:56 AMnguyen tuan
01/02/2024, 6:57 AMkhalid64927
01/02/2024, 9:04 AMnguyen tuan
01/02/2024, 9:59 AMkhalid64927
01/03/2024, 3:56 AMnguyen tuan
01/03/2024, 5:31 AMBuild was configured to prefer settings repositories over project repositories but repository ‘Yarn Distributions at https://github.com/yarnpkg/yarn/releases/download’ was added by unknown code.I also tryied to add yarn download inside settings.gradle but i not work. Can you give me some advises?
khalid64927
01/03/2024, 6:01 AMnguyen tuan
01/03/2024, 6:04 AMkhalid64927
01/03/2024, 7:08 AM./gradlew kotlinStoreYarnLock
And if you get below error follow instruction
* What went wrong:
Execution failed for task ':kotlinStoreYarnLock'.
> yarn.lock was changed. Run the `kotlinUpgradeYarnLock` task to actualize yarn.lock file
Then run
./gradlew kotlinUpgradeYarnLock
nguyen tuan
01/03/2024, 7:19 AMBuild was configured to prefer settings repositories over project repositories but repository ‘Yarn Distributions at https://github.com/yarnpkg/yarn/releases/download’ was added by unknown code.After that if i run ./gradlew kotlinUpgradeYarnLock, it will got this error message: Task ‘kotlinUpgradeYarnLock’ not found in root project ‘kmmsharelib’. What should i do now?
khalid64927
01/03/2024, 8:20 AMnguyen tuan
01/03/2024, 8:40 AM