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

kotlin.native.internal.FileFailedToInitializeException: There was an error during file or class initialization #799

Open
sunilhs1986 opened this issue Jan 1, 2025 · 3 comments
Labels
need-info Required more details about issue

Comments

@sunilhs1986
Copy link

sunilhs1986 commented Jan 1, 2025

Strings.kt:
package com.qvc.kmp.poc.shared

import dev.icerock.moko.resources.StringResource
import dev.icerock.moko.resources.desc.Resource
import dev.icerock.moko.resources.desc.StringDesc
import dev.icerock.moko.resources.format

actual class Strings {
actual fun get(id: StringResource, args: List): String {
return if(args.isEmpty()) {
StringDesc.Resource(id).localized()
} else {
id.format(*args.toTypedArray()).localized()
}
}
}

SwiftUi:
Text(
Strings().get(id: SharedRes.strings().product_description, args: [])
)

Function doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError. It is considered unexpected and unhandled instead. Program will be terminated. Uncaught Kotlin exception: kotlin.native.internal.FileFailedToInitializeException: There was an error during file or class initialization

Can someone help here ?

@sunilhs1986 sunilhs1986 changed the title Cannot convert value of type 'String' to expected argument type 'StringResource' Function doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError. It is considered unexpected and unhandled instead. Program will be terminated. Uncaught Kotlin exception: kotlin.native.internal.FileFailedToInitializeException: There was an error during file or class initialization Jan 6, 2025
@Alex009
Copy link
Member

Alex009 commented Feb 2, 2025

your error can be related to #796 that will be fixed in 0.24.5. or it can be just misconfiguration if you use static framework and not call copyResources task from xcode.

@Alex009 Alex009 changed the title Function doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError. It is considered unexpected and unhandled instead. Program will be terminated. Uncaught Kotlin exception: kotlin.native.internal.FileFailedToInitializeException: There was an error during file or class initialization kotlin.native.internal.FileFailedToInitializeException: There was an error during file or class initialization Feb 2, 2025
@Alex009 Alex009 modified the milestone: 0.24.5 Feb 2, 2025
@Alex009 Alex009 added the need-info Required more details about issue label Feb 2, 2025
@MartinStrambach
Copy link

I assume @sunilhs1986 has the same problem as I do. The configuration of my modularized project is as follows:

  • Core framework where I link static multiplatform framework ./gradlew :shared:embedAndSignAppleFrameworkForXcode
  • Application target where I run "$SRCROOT/../gradlew" -p "$SRCROOT/../shared" :shared:copyFrameworkResourcesToApp

This configuration still crashes with 0.24.5 with the same error. When I move copyFrameworkResourcesToApp to Core framework it works.
@Alex009 Is this behaviour as intented?

@Alex009
Copy link
Member

Alex009 commented Feb 3, 2025

@MartinStrambach looks like not intended. copyFrameworkResourcesToApp should be called for module that produce static framework.
can you give me reproducer project to debug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-info Required more details about issue
Projects
None yet
Development

No branches or pull requests

3 participants