Search code examples
androidkotlinkotlin-multiplatform

Build failed in KMM project in IOS Emulator due to Xcode Run Script phase without specified outputs


I'm working on a Kotlin Multiplatform Mobile project, and while trying to build the iOS side, I'm encountering a build failure related to a script build phase. Here's the warning I'm receiving:

warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'iosApp' from project 'iosApp')

This is followed by a build failure message:

The following build commands failed:
PhaseScriptExecution Run\ Script /Users/moataz/AndroidStudioProjects/MyApplication/build/ios/iosApp.build/Debug-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh (in target 'iosApp' from project 'iosApp') (1 failure)

I am unsure how to address this warning and subsequent error within the environment. Has anyone faced a similar issue when building the iOS part of KMM projects in Android Studio? Any suggestions on how to address this or further diagnose the problem would be greatly appreciated.


Solution

  • Update kotlin version in build.gradle.kts file of the parent module like this:

    plugins {
        //trick: for the same plugin versions in all sub-modules
        id("com.android.application").version("8.1.0").apply(false)
        id("com.android.library").version("8.1.0").apply(false)
        kotlin("android").version("1.9.10").apply(false)
        kotlin("multiplatform").version("1.9.10").apply(false)
       }
    

    With this change, please also update the kotlin compiler extension version inside build.gralde.kts file of androidApp like this:

    composeOptions {
            kotlinCompilerExtensionVersion = "1.5.3"
        }
    

    Refer this link for the compatibility version. This change will fix the build issue on Xcode15.

    I have created this PR for fixing the build issue in KMM Production Sample repo.