https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
s

Slackbot

02/21/2024, 11:52 AM
This message was deleted.
l

louiscad

02/21/2024, 1:13 PM
Hi @Djuro, please edit your message to move this long snippet into a "text snippet" inside this thread.
👍 1
d

Dima Avdeev

02/21/2024, 1:47 PM
Hello! In future - can you please attach big lines of code to thread for Slack message.
About your problem. We recomend for now to use new wizard to create a project: https://kmp.jetbrains.com/ Can you please try to start a new project and try to add sqldelight from scratch?
d

Djuro

02/21/2024, 2:53 PM
yes, in future I will do so,
But I can't just move the whole project, it's a large project now. Is there any guide on how to migrate
build.gradle.kts
Copy code
import org.jetbrains.compose.ExperimentalComposeLibrary

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.androidApplication)
    alias(libs.plugins.jetbrainsCompose)
    alias(libs.plugins.gradle.buildconfig.plugin)
    alias(libs.plugins.kotlinSerilization)
    alias(libs.plugins.sqldelight)
    id("dev.icerock.mobile.multiplatform-resources")
}

repositories {
    google()
    mavenCentral()
}

kotlin {
    applyDefaultHierarchyTemplate()
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "11"
            }
        }
    }

    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach { iosTarget ->
        iosTarget.binaries.framework {
            linkerOpts.add("-lsqlite3") // not needed but I remember it being needed before
            baseName = "ComposeApp"
            isStatic = false // THIS HAD TO BE CHANGED FOR SQLDELIGHT TO WORK
            // isStatic = true // this had to be changed  for MOKO-RESOURCES to work
        }
    }

    sourceSets {
        androidMain.dependencies {
            implementation(libs.compose.ui)
            implementation(libs.compose.ui.tooling.preview)
            implementation(libs.androidx.activity.compose)
            implementation(libs.ktor.client.android)
            implementation(libs.decompose)
            implementation(libs.sqldelight.android)
            implementation(libs.koin.android)
        }
        iosMain.dependencies {
            implementation(libs.ktor.client.darwin)
            implementation(libs.sqldelight.native)
        }
//        val iosSimulatorArm64Main by getting {
//            dependsOn(commonMain.get())
//        }
        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material3)
            @OptIn(ExperimentalComposeLibrary::class)
            implementation(compose.components.resources)
            implementation(libs.kotlinx.datetime)
            implementation(libs.bundles.ktor)
            implementation(libs.kotlinx.serialization)
            implementation(libs.ktor.client.logging)
            implementation(libs.ktor.client.auth)
            implementation(libs.kermit)
            implementation(libs.moko.resources)
            implementation(libs.moko.resources.compose)
            implementation(libs.multiplatform.settings)
            implementation(libs.multiplatform.settings.noarg)
            implementation(libs.decompose)
            implementation(libs.decompose.compose)
            implementation(libs.kamel)
            implementation(libs.compose.fontawesome.icons)
            implementation(libs.koin.core)
            implementation(libs.kotlinx.immutable.collections)
            implementation(libs.sqldelight.coroutines)
        }
    }
}

android {
    namespace = "?"
    compileSdk = libs.versions.android.compileSdk.get().toInt()

    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    sourceSets["main"].res.srcDirs("src/androidMain/res")
    sourceSets["main"].resources.srcDirs("src/commonMain/resources")

    defaultConfig {
        applicationId = "?"
        minSdk = libs.versions.android.minSdk.get().toInt()
        targetSdk = libs.versions.android.targetSdk.get().toInt()
        versionCode = 1
        versionName = "1.0"
    }
    buildFeatures {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
    }
    packaging {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
        }
    }
    buildTypes {
        getByName("release") {
            isMinifyEnabled = false
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
    dependencies {
        debugImplementation(libs.compose.ui.tooling)
    }
}

multiplatformResources {
    resourcesPackage.set("?")
}

buildConfig {
    buildConfigField(
        "String",
        "BASE_URL",
        "\"???""
    )
}

sqldelight {
    databases {
        create("LunchBreakDatabase") {
            packageName.set("org.example.lunchbreak")
        }
    }
}
2 Views