s

    Solomon Tolu Samuel

    8 months ago
    Hello, I am getting this error on my newly created KMM project when i try to run the IOS app from android studio
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    A problem occurred configuring project ':shared'.
    > The project must have a target for at least one of the following platforms: ios_simulator_arm64.
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at <https://help.gradle.org>
    
    BUILD FAILED in 415ms
    ** BUILD FAILED **
    
    
    The following build commands failed:
    	PhaseScriptExecution [CP-User]\ Build\ shared /Users/tolusolomon/AndroidStudioProjects/MyApplication/build/ios/Pods.build/Debug-iphonesimulator/shared.build/Script-4552119A071AC6BAB7327E6434237EC3.sh (in target 'shared' from project 'Pods')
    (1 failure)
    Command PhaseScriptExecution failed with a nonzero exit code
    And a build time error when i try to run the iosApp on Xcode:
    "cannot find 'Greeting 'in scope"
    and also this error
    Failed to register bundle identifier (The app identifier "orgIdentifier.iosApp" cannot be registered to your development team because it is not available. Change your bundle identifier to a unique string to try again.)
    please help out, thanks
    p

    Paul Weber

    8 months ago
    Failed to register bundle identifier (The app identifier “orgIdentifier.iosApp” cannot be registered to your development team because it is not available. Change your bundle identifier to a unique string to try again.)
    This doesn’t matter for now since you’re only building for a simulator. Bundle identifiers, provisioning profiles, etc. are needed when building to a device or distributing the app.
    “cannot find ’Greeting ‘in scope”
    This is probably because your kotlin module wasn’t built properly, therefore Greeting is unknown to the swift layer.
    A problem occurred configuring project ‘😒hared’.
    The project must have a target for at least one of the following platforms: ios_simulator_arm64.
    That’s your problem. Could you reply with your
    build.gradle.kts
    ? Otherwise we won’t find out where your problem is.
    s

    Solomon Tolu Samuel

    8 months ago
    plugins {
        kotlin("multiplatform")
        kotlin("native.cocoapods")
        id("com.android.library")
    }
    
    version = "1.0"
    
    kotlin {
        android()
        iosX64()
        iosArm64()
        //iosSimulatorArm64() sure all ios dependencies support this target
    
        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
            val commonTest by getting {
                dependencies {
                    implementation(kotlin("test-common"))
                    implementation(kotlin("test-annotations-common"))
                }
            }
            val androidMain by getting
            val androidTest by getting {
                dependencies {
                    implementation(kotlin("test-junit"))
                    implementation("junit:junit:4.13.2")
                }
            }
            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 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 = 32
        sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
        defaultConfig {
            minSdk = 21
            targetSdk = 32
        }
    }
    This is the "build.gradle.kts(😒hared)"
    i saw a similar issue on stackoverflow: https://stackoverflow.com/a/70412493/13307007 but the answer doesn't fix it
    What i found to be the solution was to uncomment the "iosSimulatorArm64()" in the "build.gradle.kts(😒hared)" but i dont know how ideal it is because whenever i run the iosApp on android studio it keeps on closing but it runs fine on Xcode
    kotlin {
    android()
    iosX64()
    iosArm64()
    iosSimulatorArm64() //sure all ios dependencies support this target
    
    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "14.1"
        podfile = project.file("../iosLink/Podfile")
        framework {
            baseName = "shared"
        }
    }
    
    sourceSets {
        val commonMain by getting
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        val androidMain by getting
        val androidTest by getting {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("junit:junit:4.13.2")
            }
        }
        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 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)
        }
    }