Giter Club home page Giter Club logo

Comments (3)

artdfel avatar artdfel commented on June 14, 2024 5

Okay then, I'm closing this one as a duplicate. I also found you posted the question to the StackOverflow and answered there, please check if my advice helps.

from kotlin-native.

artdfel avatar artdfel commented on June 14, 2024

Hello, @lehanphong!
First of all, I got to remind you that Kotlin/Native issue tracker is in the process of migration onto the YouTrack(#4079).
So, if you want to report a bug or propose a feature - please use this link - https://kotl.in/issue. For usage-related questions - please ask on StackOverflow with kotlin-native tag: https://stackoverflow.com/questions/ask?tags=kotlin-native. For community discussions - use #kotlin-native and #multiplatform channels in Slack workspace for Kotlin community -- https://slack.kotl.in.
About this particular question - this one seems like an incorrect build configuration, rather than a bug. Please share your Gradle script contents so anything more specific can be said. Check if there is an iosArm32 or iosArm64 target in it - those are for targeting a device. If there is only iosX64, this behavior can be assumed as expectable.

from kotlin-native.

lehanphong avatar lehanphong commented on June 14, 2024

yes, I created a new issue on youtrack, https://youtrack.jetbrains.com/issue/KT-39118

@artdfel This is my build.gradle.kts (same with https://play.kotlinlang.org/hands-on/Targeting%20iOS%20and%20Android%20with%20Kotlin%20Multiplatform/06_SettingUpKotlinFramework)

plugins {
kotlin("multiplatform")
}

kotlin {
//select iOS target platform depending on the Xcode environment variables
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64

iOSTarget("ios") {
    binaries {
        framework {
            baseName = "SharedCode"
        }
    }
}

jvm("android")

sourceSets["commonMain"].dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
}

sourceSets["androidMain"].dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib")
}

}

val packForXcode by tasks.creating(Sync::class) {
val targetDir = File(buildDir, "xcode-frameworks")

/// selecting the right configuration for the iOS
/// framework depending on the environment
/// variables set by Xcode build
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val framework = kotlin.targets
    .getByName<KotlinNativeTarget>("ios")
    .binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)

from({ framework.outputDirectory })
into(targetDir)

/// generate a helpful ./gradlew wrapper with embedded Java path
doLast {
    val gradlew = File(targetDir, "gradlew")
    gradlew.writeText("#!/bin/bash\n"
            + "export 'JAVA_HOME=${System.getProperty("java.home")}'\n"
            + "cd '${rootProject.rootDir}'\n"
            + "./gradlew \$@\n")
    gradlew.setExecutable(true)
}

}

tasks.getByName("build").dependsOn(packForXcode)

from kotlin-native.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.