简体   繁体   English

将 Snowplow 添加到适用于 iOS 的 Kotlin 多平台项目

[英]Adding Snowplow to Kotlin multiplatform project for iOS

I am trying to integrate Snowplow to a Kotlin Multiplatform Project.我正在尝试将Snowplow集成到 Kotlin 多平台项目中。

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.但是集成iOS Cocoapod会带来一些麻烦。 I added the cocoapod plugin:我添加了 cocoapod 插件:

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

And the Snowlow pod:和 Snowlow 吊舱:

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

Gradle sync results in the following error: Gradle 同步导致以下错误:

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.作为 Android 开发人员,我对 pod 及其错误的了解基本上为零。 I appreciate any hint towards a solution, as Google didn't help so far.我感谢任何有关解决方案的提示,因为到目前为止 Google 没有提供帮助。

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. cocoapods 块中 Podspec 文件的summaryhomepageframeworkName
version is a version of the Gradle project. version是 Gradle 项目的一个版本。

As I can see from the question, there is only pod() right now.正如我从问题中看到的,现在只有pod() Also, as the documentation and @Webfreak suggest, adding deploymentTarget might also help here.此外,正如文档和@Webfreak 所建议的那样,添加deploymentTarget也可能在这里有所帮助。

I believe you also need to specify path to the podfile and (not sure if required) deployment target like this:我相信您还需要指定 podfile 的路径和(不确定是否需要)部署目标,如下所示:

 cocoapods {
    ....
    podfile = project.file("../iosApp/Podfile")
    ios.deploymentTarget = "10.0"
 }

Also try to manually run cocoapod gradle tasks podImport and podInstall也尝试手动运行 cocoapod gradle 任务podImportpodInstall

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM