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

Building iOS targets fail with Kotlin 1.6.20 #4019

Closed
kubode opened this issue Apr 12, 2022 · 8 comments
Closed

Building iOS targets fail with Kotlin 1.6.20 #4019

kubode opened this issue Apr 12, 2022 · 8 comments

Comments

@kubode
Copy link
Contributor

kubode commented Apr 12, 2022

Summary
After updating Kotlin to 1.6.20, the build task fails with an "Unresolved reference" error.

Version
3.2.2

Description

How to reproduce

See my sample project: https://github.com/kubode/ApolloKotlin1620Bug
Then run ./gradlew build and you will see the following errors.

> Task :shared:compileIosMainKotlinMetadata FAILED
e: /.../ApolloKotlin1620Bug/shared/src/iosMain/kotlin/com/github/kubode/apollokotlin1620bug/Platform.kt: (3, 12): Unresolved reference: apollographql
e: /.../ApolloKotlin1620Bug/shared/src/iosMain/kotlin/com/github/kubode/apollokotlin1620bug/Platform.kt: (8, 43): Unresolved reference: SqlNormalizedCacheFactory
e: /.../ApolloKotlin1620Bug/shared/src/iosMain/kotlin/com/github/kubode/apollokotlin1620bug/Platform.kt: (9, 17): Unresolved reference: SqlNormalizedCacheFactory

Codes

iosMain's actual class implementation:

image

It seems to reference the JVM actual class as metadata.

image

I think apollo-kotlin needs to migrate Kotlin to 1.6.20.

Workaround

If you set kotlin.mpp.hierarchicalStructureSupport=false in gradle.properties, this error will not happen.

@kubode kubode changed the title Build fails with Kotlin 1.6.20 Building iOS targets fail with Kotlin 1.6.20 Apr 12, 2022
@kubode
Copy link
Contributor Author

kubode commented Apr 12, 2022

Sorry, I continued to investigate and it may be a bug in Kotlin, not Apollo.
https://youtrack.jetbrains.com/issue/KT-51763
https://youtrack.jetbrains.com/issue/KT-51293

@kubode
Copy link
Contributor Author

kubode commented Apr 12, 2022

Close because it seems to be a bug in Kotlin for sure.

@kubode kubode closed this as completed Apr 12, 2022
@martinbonnin
Copy link
Contributor

Thanks for the investigations and heads up! Looks like there are a lot of moving parts at the moment in native world. this issue mentions setting org.gradle.configureondemand=false. Did that work for you?

@kubode
Copy link
Contributor Author

kubode commented Apr 12, 2022

Thank you for your information!
Unfortunatelly, settings org.gradle.configureondemand=false was not fix the problem on this sample project.

@martinbonnin
Copy link
Contributor

martinbonnin commented Apr 14, 2022

Hi 👋 .

Thanks a lot for the reproducer! After digging a bit into this, I think this is "working as designed", not sure it's a Kotlin bug.

For more details: Apollo Kotlin doesn't support HMPP yet because some dependencies like Okio do not support it yet and I understand it's something that's a hard requirement. Kotlin 1.6.20 enabled HMPP by default which creates this issue. But if I disable HMPP in the ApolloKotlin1620Bug reproducer project, I can run ./gradlew build successfully.

It might be that you still have the error in your full scale project though? And not the ApolloKotlin1620Bug reproducer? I bumped into other bugs while updating to 1.6.20 in the project itself and had to do a few workarounds

@kubode
Copy link
Contributor Author

kubode commented Apr 14, 2022

Thanks for the detailed info!
I guess I did not understand HMPP correctly 😞

In my full scale project, ./gradlew publish succeeds by setting kotlin.mpp.hierarchicalStructureSupport=false.
(./gradlew publish fails with :shared:compareIosMainKotlinMetadata task unless setting kotlin.mpp.hierarchicalStructureSupport=false)
I haven't tried to run ./gradlew build on my project due to it takes a too long time.

I saw your workaround in build.gradle.kts, but it's not necessary for my project.

@martinbonnin
Copy link
Contributor

Not really sure I got HMPP correctly either... 😅
My understanding is that kotlin.mpp.hierarchicalStructureSupport=false is still required for the time being for consumers of projects like okio or apollo.

If you still have an error with kotlin.mpp.hierarchicalStructureSupport=false, do you mind copy/pasting the stacktrace? It might be something else.

@kubode
Copy link
Contributor Author

kubode commented Apr 14, 2022

I’m not have any errors with kotlin.mpp.hierarchicalStructureSupport=false. Thanks!

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

No branches or pull requests

2 participants