Hello, I’m trying to setup fritz2 with a project t...
# javascript
s
Hello, I’m trying to setup fritz2 with a project that includes native applications. So, I got the application running but it cannot find the
.js
file in
index.html
My current problem is that there are two build folders being created. 1 in project folder and one in shared folder.
o
With over 35000 people on this channel, many on mobile, can you please keep initial posts short and put code blocks and followup questions in a thread?
s
sure will do!
👍 1
This is my build.gradle in the shared folder.
Copy code
plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("com.android.library")
    id("com.google.devtools.ksp") version "1.6.10-1.0.2"
}

repositories {
    mavenCentral()
    maven("<https://s01.oss.sonatype.org/content/repositories/snapshots/>")
}

version = "1.0"
val fritz2Version = "1.0-RC1"

kotlin {
    jvm()
    js(IR) {
        browser()
    }.binaries.executable()
    android()
    iosX64()
    iosArm64()
    iosSimulatorArm64()

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "14.1"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "shared"
        }
    }
    
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("dev.fritz2:core:$fritz2Version")
                // implementation("dev.fritz2:headless:$fritz2Version") // optional
            }
        }
        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 jvmMain by getting {
            dependencies {
            }
        }
        val jsMain by getting {
            dependsOn(commonMain)
            dependencies {
//                implementation("dev.fritz2:core:$fritz2Version")
                // tailwind
                implementation(npm("tailwindcss", "3.0.19"))
                // implementation(npm("@tailwindcss/forms", "0.4.0")) // optional

                // webpack
                implementation(devNpm("postcss", "8.4.6"))
                implementation(devNpm("postcss-loader", "6.2.1"))
                implementation(devNpm("autoprefixer", "10.4.2"))
                implementation(devNpm("css-loader", "6.6.0"))
                implementation(devNpm("style-loader", "3.3.1"))
                implementation(devNpm("cssnano", "5.0.17"))
            }
        }
        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)
        }
    }
}

android {
    compileSdk = 33
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdk = 23
        targetSdk = 33
    }
}

/**
 * KSP support - start
 */
dependencies {
    add("kspMetadata", "dev.fritz2:lenses-annotation-processor:$fritz2Version")
}
kotlin.sourceSets.commonMain { kotlin.srcDir("build/generated/ksp/commonMain/kotlin") }
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().all {
    if (name != "kspKotlinMetadata") dependsOn("kspKotlinMetadata")
}

rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
    rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "16.0.0"
}

afterEvaluate {
    rootProject.extensions.configure<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension> {
        versions.webpackCli.version="4.10.0"
    }
}
/**
 * KSP support - end
 */
I suppose the question should be how to change the js target so that the js file is built in the shared/build folder
b
Off topic, but are you aware of #fritz2 channel? Not directly relevant for this particular issue though.
s
Sorry wasn't aware. Joined here today… will try that channel thanks!
b
No, don't get me wrong. Your issue is not fritz2 specific and is very applicable to this channel. Just thought I'd mention #fritz2 for the future
s
Oh okay thanks! Appreciate it!