Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS tests crash after update to kotlin 2.1.0 and moko-resources 0.24.4 #796

Closed
Burtan opened this issue Dec 18, 2024 · 6 comments · Fixed by #803
Closed

iOS tests crash after update to kotlin 2.1.0 and moko-resources 0.24.4 #796

Burtan opened this issue Dec 18, 2024 · 6 comments · Fixed by #803
Assignees
Milestone

Comments

@Burtan
Copy link
Contributor

Burtan commented Dec 18, 2024

Hey,
I updated to kotlin 2.1.0 and moko-resources 0.24.4 and now my iOS tests crash:

kotlin.native.internal.FileFailedToInitializeException: There was an error during file or class initialization
at kotlin.Error#(/opt/buildAgent/work/b5c630f73501b353/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:14)
at kotlin.native.internal.FileFailedToInitializeException#(/opt/buildAgent/work/b5c630f73501b353/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt:116)
at .ThrowFileFailedToInitializeException(/opt/buildAgent/work/b5c630f73501b353/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt:128)
at .CallInitGlobalPossiblyLock(Unknown Source)

Here is an example project.

@an22
Copy link

an22 commented Dec 27, 2024

I am experiencing the same issue.

This issue seems to be reproduced only in a multi-module application, since I tested it on kotlin2_sample with Kotlin 2.1.0 and it worked fine.

Reproduced in:

Xcode Version 16.2 (16C5032a)
iOS 18.* (Tested on 18.1, 18.2)

Reproduction project included:

kotlin2_sample_FileFailedToInitializeException.zip

@kevincianfarini
Copy link
Contributor

We're also being affected by this.

@jasvilladarez
Copy link

We are experiencing the same issue. Any workaround for this?

@kevincianfarini
Copy link
Contributor

It is perhaps worth noting that Kotlin/Native 2.1.0 is a forwards incompatible change, meaning that libraries built with Kotlin 2.1.0 will not be able to be consumed from Kotlin 2.0.21 and before. Trying to do so results in a message similar to the following:

w: KLIB resolver: Skipping '/Users/runner/work/Flapjack/Flapjack/.ci-gradle-home/caches/modules-2/files-2.1/com.squareup.okio/okio-iossimulatorarm64/3.10.1/bf082b70caf16fc3896370a0fdd633610c89b4f4/okio-iosSimulatorArm64Main-3.10.1.klib'. 
Incompatible ABI version. The current default is '1.8.0', found '1.201.0'. 
The library was produced by '2.1.0' compiler.

This is preventing my team, and will likely prevent everyone using this library, from upgrading dependencies until this is worked around or resolved. So far we've had to park to kotlinx-coroutines 1.10.1 and okio 3.10.1 dependency upgrades.

@kevincianfarini
Copy link
Contributor

After some more research, we discovered that:

  1. Tests involving moko passed locally when we had pre-built our application.
  2. Running a Gradle clean allowed us to reproduce the issue we were seeing on CI locally.

@an22
Copy link

an22 commented Jan 11, 2025

@kevincianfarini @jasvilladarez

I am using this script as a workaround, maybe it will be helpful in your case. It walks through folders and finds all .bundle packages and copies it into framework package. It may be not the most optimal way but it works for me.
Add it as a last build phase in your XCode target build phases.
Make sure to replace your_framework_name with your actual framework name (shared in my case)

it'll most certainly not going to work in static framework case since recources packaged separately in static case.

Shell: /bin/bash

cd "$SRCROOT/.."
#https://github.com/icerockdev/moko-resources/issues/796
str="$FRAMEWORK_SEARCH_PATHS"
IFS=' ' read -r -a parts <<< "$str"
for i in "${parts[@]}"; do
    find . -name "*.bundle" -exec rsync -r {} "$i/your_framework_name.framework/" \;
done

@Alex009 Alex009 self-assigned this Feb 1, 2025
@Alex009 Alex009 added this to the 0.24.5 milestone Feb 1, 2025
Alex009 added a commit that referenced this issue Feb 1, 2025
@Alex009 Alex009 linked a pull request Feb 1, 2025 that will close this issue
Alex009 added a commit that referenced this issue Feb 2, 2025
Alex009 added a commit that referenced this issue Feb 2, 2025
Alex009 added a commit that referenced this issue Feb 2, 2025
Alex009 added a commit that referenced this issue Feb 2, 2025
Alex009 added a commit that referenced this issue Feb 2, 2025
Alex009 added a commit that referenced this issue Feb 2, 2025
@Alex009 Alex009 mentioned this issue Feb 2, 2025
@Alex009 Alex009 closed this as completed Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants