Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【copyFrameworkResourcesToApp】Need support platform arm64 iphonesimulator. #417

Closed
xiaoyvyv opened this issue Feb 7, 2023 · 2 comments · Fixed by #437
Closed

【copyFrameworkResourcesToApp】Need support platform arm64 iphonesimulator. #417

xiaoyvyv opened this issue Feb 7, 2023 · 2 comments · Fixed by #437
Assignees
Labels
bug Something isn't working
Milestone

Comments

@xiaoyvyv
Copy link

xiaoyvyv commented Feb 7, 2023

Execution failed for task ':shared:copyFrameworkResourcesToApp'.

framework link task with konanTarget ios_x64, platform iphonesimulator and buildType DEBUG not found!

@xiaoyvyv
Copy link
Author

xiaoyvyv commented Feb 7, 2023

task ':shared:copyFrameworkResourcesToApp'. not support arm64 iphonesimulator

/*
 * Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.gradle.tasks

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.konan.target.KonanTarget

open class CopyFrameworkResourcesToAppEntryPointTask : DefaultTask() {

    @get:Internal
    internal val konanTarget: KonanTarget?

    @get:Internal
    internal val configuration: String?
        get() {
            val configurationName =
                (project.findProperty("moko.resources.CONFIGURATION") as? String)

            return configurationMapper[configurationName]?.name ?: configurationName
        }

    @get:Internal
    internal val platformName: String?

    @get:Internal
    internal var configurationMapper: Map<String, NativeBuildType> = emptyMap()

    init {
        group = "moko-resources"

        platformName =
            project.findProperty("moko.resources.PLATFORM_NAME") as? String

        konanTarget = when (platformName) {
            "iphonesimulator" -> KonanTarget.IOS_X64
            "iphoneos" -> KonanTarget.IOS_ARM64
            "macosx" -> KonanTarget.MACOS_X64
            else -> null
        }
    }

    @TaskAction
    fun action() {
        if (dependsOn.isEmpty()) {
            throw IllegalStateException(
                """
framework link task with konanTarget $konanTarget, platform $platformName and buildType $configuration not found!
"""
            )
        }
    }
}

Error

> Task :shared:copyFrameworkResourcesToApp FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared:copyFrameworkResourcesToApp'.
> 
  framework link task with konanTarget ios_x64, platform iphonesimulator and buildType DEBUG not found!

build.gradle.kts

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("com.android.library")
    id("org.jetbrains.compose")
    id("dev.icerock.mobile.multiplatform-resources")
}

kotlin {
    android {
        compilations.all {
            kotlinOptions {
                jvmTarget = "11"
            }
        }
    }

    // iosArm64("iosApp")
    iosSimulatorArm64("iosApp")

    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"
            isStatic = true

            export("dev.icerock.moko:resources:0.20.1")
            export("dev.icerock.moko:graphics:0.9.0")
        }
        val script = """
                spec.script_phases = [
                    {
                        :name => 'Build shared',
                        :execution_position => :before_compile,
                        :shell_path => '/bin/sh',
                        :script => <<-SCRIPT
                            if [ "YES" = "${'$'}OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then
                              echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\""
                              exit 0
                            fi
                            set -ev
                            REPO_ROOT="${'$'}PODS_TARGET_SRCROOT"
                            "${'$'}REPO_ROOT/../gradlew" -p "${'$'}REPO_ROOT" ${'$'}KOTLIN_PROJECT_PATH:syncFramework \
                                -Pkotlin.native.cocoapods.platform=${'$'}PLATFORM_NAME \
                                -Pkotlin.native.cocoapods.archs="${'$'}ARCHS" \
                                -Pkotlin.native.cocoapods.configuration="${'$'}CONFIGURATION"
                            "${'$'}REPO_ROOT/../gradlew" -p "${'$'}REPO_ROOT" :shared:copyFrameworkResourcesToApp \
                                -Pmoko.resources.PLATFORM_NAME=${'$'}PLATFORM_NAME \
                                -Pmoko.resources.CONFIGURATION=${'$'}CONFIGURATION \
                                -Pmoko.resources.BUILT_PRODUCTS_DIR=${'$'}BUILT_PRODUCTS_DIR \
                                -Pmoko.resources.CONTENTS_FOLDER_PATH=${'$'}CONTENTS_FOLDER_PATH\
                                -Pkotlin.native.cocoapods.platform=${'$'}PLATFORM_NAME \
                                -Pkotlin.native.cocoapods.archs="${'$'}ARCHS" \
                                -Pkotlin.native.cocoapods.configuration=${'$'}CONFIGURATION
                        SCRIPT
                    }
                ]
        """.trimIndent()

        extraSpecAttributes["script_phases"] = script
    }

@Alex009 Alex009 added this to the 0.20.2 milestone Feb 10, 2023
@Alex009 Alex009 self-assigned this Feb 10, 2023
@Alex009 Alex009 added the bug Something isn't working label Feb 10, 2023
kramlex pushed a commit to kramlex/moko-resources that referenced this issue Mar 10, 2023
@Alex009 Alex009 linked a pull request Mar 10, 2023 that will close this issue
Alex009 added a commit to kramlex/moko-resources that referenced this issue Mar 10, 2023
Alex009 added a commit to kramlex/moko-resources that referenced this issue Mar 10, 2023
Alex009 added a commit that referenced this issue Mar 10, 2023
…-support

#417 add arm64simulator target support
@Alex009
Copy link
Member

Alex009 commented Mar 10, 2023

will be released in 0.21.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants