Search code examples
android-studiococoapodskotlin-multiplatform

Adding pod dependency to Kotlin Multiplatform result in compilation error (non-zero exit code 1)


Using a pod dependency (In my case, it is lottie-ios) in my kotlin multiplatform mobile project causes it to not compile at all with the following error:

Failed to generate cinterop for :shared:cinteropLottie-iosIosArm64: Process 'command '/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java'' finished with non-zero exit value 1

This is my cocoapods block:

cocoapods {
        summary = "Common Code (Platform-agnostic)"
        homepage = "."
        version = "1.0.0"
        ios.deploymentTarget = "14.1"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "shared"
        }

        pod("lottie-ios") {
            version = "4.3.3"
        }
    }

Solution

  • Based on this ticket solution, I needed to change my pod dependency block to make sure that the module name is the same as when I import the module to a Swift file, this is the result:

     pod("lottie-ios") {
        moduleName = "Lottie" //The module name is the same as when you do "import" in a swift file (import Lottie)
        version = "4.3.3"
    }
    

    If I use any other module name, it will not compile.