将Kotlinx-Datetime添加到我的Kotlin Multiplatform应用程序中断iOS构建

发布于 2025-02-06 14:44:47 字数 1150 浏览 2 评论 0原文

我能够成功运行Android Studio在Android和iOS中生成的示例应用程序。在向导步骤中,我选择了Cocoapods。

但是,当我添加 kotlinx-datetime 到我的依赖项,我只能为Android运行该应用程序。

我的build.gradle.kts:

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.0")
            }
        }
    ...

添加库时,我会收到以下错误:

> Task :shared:linkDebugFrameworkIosX64 FAILED
e: Compilation failed: Expecting descriptor for kotlin.time/TimeMark.<init>|-5645683436151566731[0]

 * Source files: 
 * Compiler version info: Konan: 1.7.0 / Kotlin: 1.7.20
 * Output kind: STATIC_CACHE

e: java.lang.IllegalStateException: Expecting descriptor for kotlin.time/TimeMark.<init>|-5645683436151566731[0]

如何复制:

  1. 使用AS创建KMM示例应用程序。
  2. 添加库:实现(“ org.jetbrains.kotlinx:kotlinx-datetime:0.3.0”) to build.gradle.kts中的commanmain
  3. 尝试以任何方式使用/import/import/import/import localdate

有什么想法解决这个问题吗?

I was able to successfully run the sample app generated by Android Studio in both Android and iOS. I chose CocoaPods during the Wizard steps.

But when I add kotlinx-datetime to my dependencies, I can only run the app for Android.

My build.gradle.kts :

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.0")
            }
        }
    ...

When adding the library I get the following error:

> Task :shared:linkDebugFrameworkIosX64 FAILED
e: Compilation failed: Expecting descriptor for kotlin.time/TimeMark.<init>|-5645683436151566731[0]

 * Source files: 
 * Compiler version info: Konan: 1.7.0 / Kotlin: 1.7.20
 * Output kind: STATIC_CACHE

e: java.lang.IllegalStateException: Expecting descriptor for kotlin.time/TimeMark.<init>|-5645683436151566731[0]

How to reproduce:

  1. Create a KMM sample app with AS.
  2. Add the library : implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.0") to the commonMain in the build.gradle.kts
  3. Try to use/import/print LocalDate in any way

Any ideas how to solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喵星人汪星人 2025-02-13 14:44:47

升级到Kotlin 1.7.0并使用Kotlinx-Datetime 0.3.2之后,我开始遇到同一问题。

如建议的在这里,升级到org.jetbrains.kotlinx:kotlinx-dateTime:kotlinx-dateTime:kotlinx-datetime: 0.3.3解决了问题。

After upgrading to Kotlin 1.7.0 and using kotlinx-datetime 0.3.2, I started to face the same issue.

As suggested here, upgrading to org.jetbrains.kotlinx:kotlinx-datetime:0.3.3 solved the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文