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

Can't compile with Kotlin 2.1.0 #786

Closed
griffinsorrentino opened this issue Nov 29, 2024 · 5 comments · Fixed by #789
Closed

Can't compile with Kotlin 2.1.0 #786

griffinsorrentino opened this issue Nov 29, 2024 · 5 comments · Fixed by #789
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@griffinsorrentino
Copy link

With Kotlin 2.1.0, the new default is to generate non-packed klib files
https://kotlinlang.org/docs/whatsnew21.html#support-for-non-packed-klibs

This is causing a FileNotFoundException (Is a directory) error because the klib file attempting to be unzipped is an unpacked klib directory and not a .klib file

Caused by: java.io.FileNotFoundException: <module name>/build/classes/kotlin/iosArm64/main/klib/<module name> (Is a directory)
	at dev.icerock.gradle.utils.ZipUtilsKt.unzipTo(ZipUtils.kt:14)
	at dev.icerock.gradle.actions.apple.PackAppleResourcesToKLibAction.execute(PackAppleResourcesToKLibAction.kt:50)
	at dev.icerock.gradle.actions.apple.PackAppleResourcesToKLibAction.execute(PackAppleResourcesToKLibAction.kt:19)

The error is linked to this function

internal fun unzipTo(outputDirectory: File, zipFile: File) {
ZipFile(zipFile).use { zip ->
val outputDirectoryCanonicalPath = outputDirectory.canonicalPath
for (entry in zip.entries()) {
unzipEntryTo(outputDirectory, outputDirectoryCanonicalPath, zip, entry)
}
}
}

File structure in Kotlin 2.0.21:
Group 31

File structure in Kotlin 2.1.0:
Group 30

Workaround:
As a temporary workaround, you can change back to packed libs - https://kotlinlang.org/docs/whatsnew21.html#how-to-set-up-your-project
Although using unpacked for the performance improvement (even if very minor) would be the ideal end goal

@Alex009 Alex009 added this to the 0.24.4 milestone Nov 30, 2024
@Alex009 Alex009 added the enhancement New feature or request label Nov 30, 2024
@Alex009 Alex009 self-assigned this Dec 4, 2024
@AndroidPat
Copy link

Hi griffinsorrentino, would you be able to show a simple example of how to force packed libs in a KMM project? I'm trying to apply the configuration without luck.

@griffinsorrentino
Copy link
Author

Hi griffinsorrentino, would you be able to show a simple example of how to force packed libs in a KMM project? I'm trying to apply the configuration without luck.

The configuration I believe is only for plugins, you can add kotlin.internal.klibs.non-packed=true/false in your properties file to force Kotlin to use packed libs

@AndroidPat
Copy link

Thank you. Unfortunately I get the same FileNotFound error with
kotlin.internal.klibs.non-packed=true

and with kotlin.internal.klibs.non-packed=false the whole project falls apart because of broken imports. @Alex009 is there any chance for any work-in-progress snapshot soon that would fix it?

@Alex009 Alex009 linked a pull request Dec 8, 2024 that will close this issue
@Alex009
Copy link
Member

Alex009 commented Dec 8, 2024

fix will be in 0.24.4

@Alex009 Alex009 closed this as completed Dec 8, 2024
@Alex009 Alex009 mentioned this issue Dec 8, 2024
@griffinsorrentino
Copy link
Author

@Alex009 Thank you for your swift resolution on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants