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.IrLinkageError #13

Open
2 tasks done
3llomi opened this issue May 9, 2024 · 15 comments
Open
2 tasks done

kotlin.native.internal.IrLinkageError #13

3llomi opened this issue May 9, 2024 · 15 comments
Labels
bug Something isn't working

Comments

@3llomi
Copy link

3llomi commented May 9, 2024

Checklist

  • I've checked that Google's libphonenumber properly handles my case on the demo website.
  • This bug report isn't about adding core functionality. Such functionality should be first added to Google's libphonenumber and then it will be ported to this repo.

Describe the bug
I'm getting this exception when trying to format a number, it's on IOS only though as it's working perfectly on Android.

//commonMain
//crash happens when calling any method related to phoneNumberUtil
val phoneNumber = phoneNumberUtil.parse(number, region)

This is the crash i'm getting on IOS.

Uncaught Kotlin exception: kotlin.native.internal.IrLinkageError: Property accessor 'nsBundle.<get-nsBundle>' can not be called: No property accessor found for symbol 'dev.icerock.moko.resources/ResourceContainer.nsBundle.<get-nsBundle>|<get-nsBundle>(){}[0]'
    at 0   shared                              0x103f6ece7        kfun:kotlin.Throwable#<init>(kotlin.String?){} + 119 (/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt:28:37)
    at 1   shared                              0x103f68217        kfun:kotlin.Error#<init>(kotlin.String?){} + 115 (/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:12:44)
    at 2   shared                              0x103f9f183        kfun:kotlin.native.internal.IrLinkageError#<init>(kotlin.String?){} + 115 (/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt:137:51)
    at 3   shared                              0x103f9f23b        kfun:kotlin.native.internal#ThrowIrLinkageError(kotlin.String?){}kotlin.Nothing + 163 (/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt:141:11)
    at 4   shared                              0x1041c90bf        kfun:io.michaelrocks.libphonenumber.kotlin.metadata.source#getAssetByFilePath__at__dev.icerock.moko.resources.ResourceContainer<dev.icerock.moko.resources.AssetResource>(kotlin.String){}dev.icerock.moko.resources.AssetResource? + 343 (/Users/lucaspinazzola/Projects/libphonenumber-kotlin/libphonenumber/src/nativeMain/kotlin/io/michaelrocks/libphonenumber/kotlin/metadata/source/MultiFileModeResourceProvider.native.kt:13:65)
    at 5   shared                              0x1041c605f        kfun:io.michaelrocks.libphonenumber.kotlin.metadata.source.MultiFileModeResourceProvider#getFor(kotlin.Any){}dev.icerock.moko.resources.AssetResource? + 639 (/Users/lucaspinazzola/Projects/libphonenumber-kotlin/libphonenumber/src/commonMain/kotlin/io/michaelrocks/libphonenumber/kotlin/metadata/source/MultiFileModeResourceProvider.kt:44:23)
    at 6   shared                              0x1041d0237        kfun:io.michaelrocks.libphonenumber.kotlin.metadata.source.PhoneMetadataResourceProvider#getFor(kotlin.Any){}dev.icerock.moko.resources.AssetResource?-trampoline + 107 (/Users/lucaspinazzola/Projects/libphonenumber-kotlin/libphonenumber/src/commonMain/kotlin/io/michaelrocks/libphonenumber/kotlin/metadata/source/PhoneMetadataResourceProvider.kt:37:5)
    at 7   shared                              0x1041c58ef        kfun:io.michaelrocks.libphonenumber.kotlin.metadata.source.MetadataSourceImpl#getMetadataForRegion(kotlin.String?){}io.michaelrocks.libphonenumber.kotlin.Phonemetadata.PhoneMetadata? + 555 (/Users/lucaspinazzola/Projects/libphonenumber-kotlin/libphonenumber/src/commonMain/kotlin/io/michaelrocks/libphonenumber/kotlin/metadata/source/MetadataSourceImpl.kt:53:80)
    at 8   shared                              0x1041ceb0f        kfun:io.michaelrocks.libphonenumber.kotlin.metadata.source.MetadataSource#getMetadataForRegion(kotlin.String?){}io.michaelrocks.libphonenumber.kotlin.Phonemetadata.PhoneMetadata?-trampoline + 107 (/Users/lucaspinazzola/Projects/libphonenumber-kotlin/libphonenumber/src/commonMain/kotlin/io/michaelrocks/libphonenumber/kotlin/metadata/source/MetadataSource.kt:24:420)
    at 9   shared                              0x1041985cb        kfun:io.michaelrocks.libphonenumber.kotlin.PhoneNumberUtil#getMetadataForRegion(kotlin.String?){}io.michaelrocks.libphonenumber.kotlin.Phonemetadata.PhoneMetadata? + 271 (/Users/lucaspinazzola/Projects/libphonenumber-kotlin/libphonenumber/src/commonMain/kotlin/io/michaelrocks/libphonenumber/kotlin/PhoneNumberUtil.kt:1664:44)
    at 10  shared                              0x10419f09f        kfun:io.michaelrocks.libphonenumber.kotlin.PhoneNumberUtil.parseHelper#internal + 1691 (/Users/lucaspinazzola/Projects/libphonenumber-kotlin/libphonenumber/src/commonMain/kotlin/io/michaelrocks/libphonenumber/kotlin/PhoneNumberUtil.kt:2620:30)
    at 11  shared                              0x10419e6e7        kfun:io.michaelrocks.libphonenumber.kotlin.PhoneNumberUtil#parse(kotlin.CharSequence?;kotlin.String?;io.michaelrocks.libphonenumber.kotlin.Phonenumber.PhoneNumber){} + 159 (/Users/lucaspinazzola/Projects/libphonenumber-kotlin/libphonenumber/src/commonMain/kotlin/io/michaelrocks/libphonenumber/kotlin/PhoneNumberUtil.kt:2498:9)
    at 12  shared                              0x10419e603        kfun:io.michaelrocks.libphonenumber.kotlin.PhoneNumberUtil#parse(kotlin.CharSequence?;kotlin.String?){}io.michaelrocks.libphonenumber.kotlin.Phonenumber.PhoneNumber + 243 (/Users/lucaspinazzola/Projects/libphonenumber-kotlin/libphonenumber/src/commonMain/kotlin/io/michaelrocks/libphonenumber/kotlin/PhoneNumberUtil.kt:2488:9)

Expected behavior
No Crash

@3llomi 3llomi added the bug Something isn't working label May 9, 2024
@luca992
Copy link
Owner

luca992 commented May 11, 2024

Are you trying to use the v0.1.1 published version, or are you building this locally?

@3llomi
Copy link
Author

3llomi commented May 11, 2024

Yes I'm using the published version 0.1.1

@luca992
Copy link
Owner

luca992 commented May 11, 2024

It looks like there's a problem the resources using moko-resources... it looks like it's trying to use files from the absolute path on my computer in your stacktrace for some reason: /Users/lucaspinazzola/Projects/libphonenumber-kotlin/libphonenumber/src/nativeMain/kotlin/io/michaelrocks/libphonenumber/kotlin/metadata/source/MultiFileModeResourceProvider.native.kt

I'll have to look into it. If you build/publish it locally I bet it would work if you are in a rush

@Miggets7
Copy link

I'm also experiencing an issue on iOS:

kotlin.IllegalArgumentException: bundle with identifier io.michaelrocks.libphonenumber.MR not found

I think it also has to do with mono-resources?

@luca992
Copy link
Owner

luca992 commented May 31, 2024

yeah, you'll have to build/publish locally for now it looks like. I haven't had time to look into how to properly package the resources on native yet. Prs are welcome.

@Miggets7
Copy link

I couldn't compile the project, not sure why.
But could this article maybe help?

https://proandroiddev.com/exposing-the-separate-resources-module-to-ios-target-using-moko-resources-in-kmm-76b9c3d533

@luca992
Copy link
Owner

luca992 commented Jun 13, 2024

@Miggets7 thanks for the link, looks like it may help. I'll try and take a look this weekend. I started a kotlin 2.0 branch (js sample and tests are broken, so it's not fully ready yet)... but not sure if that would be more likely to build for you.

@cpienovi
Copy link

cpienovi commented Aug 8, 2024

I'm also experiencing kotlin.IllegalArgumentException: bundle with identifier io.michaelrocks.libphonenumber.MR not found on iOS using Kotlin 2.0.0
Are there any workaround to it?

@luca992
Copy link
Owner

luca992 commented Aug 8, 2024

I should just switch to compose resources... it's just annoying how it forces the inclusion of skia though even if you don't use compose ui

@cpienovi
Copy link

cpienovi commented Aug 8, 2024

I've tried to implement my own MetadataLoader but it has nothing to do with it, isn't it? The resources just aren't there.
I wish I could help you with the skia thing.

@luca992
Copy link
Owner

luca992 commented Aug 8, 2024

Does the ios sample on the 2.0 branch not run for you @cpienovi ?

if you're on your own project you'll need to add this build script:

https://github.com/icerockdev/moko-resources?tab=readme-ov-file#iosmacos-static-kotlin-frameworks-support

@archieunblk
Copy link

archieunblk commented Oct 9, 2024

I couldn't compile the project, not sure why. But could this article maybe help?

https://proandroiddev.com/exposing-the-separate-resources-module-to-ios-target-using-moko-resources-in-kmm-76b9c3d533

This fixed the issue for me.

@archieunblk
Copy link

archieunblk commented Oct 18, 2024

I couldn't compile the project, not sure why. But could this article maybe help?
https://proandroiddev.com/exposing-the-separate-resources-module-to-ios-target-using-moko-resources-in-kmm-76b9c3d533

This fixed the issue for me.

Just an update. This fixed the issue but on for Simulator builds for some reason when loading on an actual device, I still encounter the same issue. 🤔

After experimenting for a while looks like you have to do both this.

and also do this:

Does the ios sample on the 2.0 branch not run for you @cpienovi ? if you're on your own project you'll need to add this build script: https://github.com/icerockdev/moko-resources?tab=readme-ov-file#iosmacos-static-kotlin-frameworks-support

to make it work.

@luca992
Copy link
Owner

luca992 commented Oct 18, 2024

I'm gonna try and port it over to compose resources soon I think. Just haven't had much free time lately

@luca992
Copy link
Owner

luca992 commented Dec 2, 2024

I migrated over to compose resources. I think it should theoretically resolve most of these issues running the sample locally. Also, I published 0.1.3 but I have no idea if compose resources is capable of bundling the resources in maven for non jvm yet. Didn't get a chance to try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants