ioskotlincocoapodskotlin-multiplatformsnowplow

Adding Snowplow to Kotlin multiplatform project for iOS


I am trying to integrate Snowplow to a Kotlin Multiplatform Project.

Android is working fine:

val androidMain by getting {
        dependencies {
            api("com.snowplowanalytics:snowplow-android-tracker:1.7.1")
        }
    }

But integrating the iOS Cocoapod causes some troubles. I added the cocoapod plugin:

plugins {
    kotlin("multiplatform") version "1.4.32"
}

And the Snowlow pod:

kotlin {
    iosX64()
    iosArm64()
    cocoapods {
        pod("SnowplowTracker") {
            version = "~> 2.1.1"
        }
    }
}

Gradle sync results in the following error:

Exception in thread "main" java.lang.Error: /var/folders/gv/rc4dmzjs3wj9kt4kr00nwhdw0000gn/T/2185483547857483783.m:1:9: fatal error: module 'SnowplowTracker' not found
    at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
    at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:68)
    at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:14)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:506)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:264)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:74)
    at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
    at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
    at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:41)

Execution failed for task ':cinteropSnowplowTrackerIosArm64'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

As I am Android developer I have basically zero knowledge about pods and their errors. I appreciate any hint towards a solution, as Google didn't help so far.


Solution

  • I would say the important thing here is to meet all requirements listed in the documentation. I'm mostly concerned if your project configures

    summary, homepage, and frameworkName of the Podspec file in the cocoapods block.
    version is a version of the Gradle project.

    As I can see from the question, there is only pod() right now. Also, as the documentation and @Webfreak suggest, adding deploymentTarget might also help here.