Hi folks, I’m facing the following problem in my c...
# compose-ios
e
Hi folks, I’m facing the following problem in my compose multiplatform project: When using
kotlin.version=1.8.20
compose.version=1.4.1
I can run iOS app, but on running Android app, the build fails:
Copy code
> Task :androidApp:compileDevDebugKotlin FAILED
e: This version (1.4.1) of the Compose Compiler requires Kotlin version 1.8.0 but you appear to be using Kotlin version 1.8.20 which is not known to be compatible. Please consult the Compose-Kotlin compatibility map located at <https://developer.android.com/jetpack/androidx/releases/compose-kotlin> to choose a compatible version pair (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).
So I changed Kotlin version to 1.8.0 and it solved the issue for Android, but then iOS has an issue: (full details in comment)
Copy code
> Task :composables:linkPodDebugFrameworkIosSimulatorArm64 FAILED
e: Module "org.jetbrains.compose.ui:ui (org.jetbrains.compose.ui:ui-uikitsimarm64)" has a reference to symbol platform.UIKit/UIView.setFrame|-3257539694696545905[100]. Neither the module itself nor its dependencies contain such declaration.

This could happen if the required dependency is missing in the project. Or if there is a dependency of "org.jetbrains.compose.ui:ui (org.jetbrains.compose.ui:ui-uikitsimarm64)" that has a different version in the project than the version that "org.jetbrains.compose.ui:ui (org.jetbrains.compose.ui:ui-uikitsimarm64): 1.4.1" was initially compiled with. Please check that the project configuration is correct and has consistent versions of all required dependencies.
Any help would be appreciated!
👍 1
j
you should be able to get around this (for first issue you mentioned anyway) by using
kotlinCompilerPluginArgs
setting....see example in following file https://github.com/joreilly/PeopleInSpace/blob/main/compose-ios/build.gradle.kts
ah, this was error for android app build....in that case you might also try updating compose compiler version for that as per https://developer.android.com/jetpack/androidx/releases/compose-kotlin
so
1.4.5
in for Kotlin
1.8.20
e
thanks @John O'Reilly still have an issue (both in Android and iOS builds)
Copy code
* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.jetbrains.compose', version: '1.4.5'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.jetbrains.compose:org.jetbrains.compose.gradle.plugin:1.4.5')
  Searched in the following repositories:
    Gradle Central Plugin Repository
    maven(<https://maven.pkg.jetbrains.space/public/p/compose/dev>)
    Google
j
so, the 1.4.5 version I mentioned above was the androidx one whereas it's complaining above about the jetbrains one....it's quite messy but depending on combination of versions you can use same for both or specific different versions for Android and for Compose Multiplatform ....there's also some more info on how to set this up (for Compose Multiplatform) in https://github.com/JetBrains/compose-multiplatform/blob/master/VERSIONING.md
which module is above complaining about?
hmm, this shows 1.4.5 for 1.8.20 as well
oh, I think you were setting compose version to 1.4.5 above?
e
which module is above complaining about?
Copy code
Build file '/Users/eladfinish/AndroidStudioProjects/elad/BibleContestMobileApp/composables/build.gradle.kts' line: 1

Plugin [id: 'org.jetbrains.compose', version: '1.4.5'] was not found in any of the following sources:
yes
j
as opposed to compose compiler version
I probably didn't make that very clear above
so basically the 3 things that generally need to line up right now are (1) Kotlin version, (2) Compose version, and (3) Compose Compiler version
e
checking. I don't want to downgrade Compose version, as the old versions require every Composable function to be internal, to work in iOS.
j
did you try something like following in your compose ios module?
Copy code
compose {
    kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.8.20")
}
(while still using Compose Multiplatform 1.4.1)
e
I tried it in android module
Copy code
kotlinOptions {
    jvmTarget = "1.8"
    freeCompilerArgs += listOf(
        "-Xallow-jvm-ir-dependencies",
        "-P",
        "plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=1.8.20",
    )
}
trying on ios
j
I think you'll need to use that top level
compose
section like I have above for your ios module (as per https://github.com/JetBrains/compose-multiplatform/blob/master/VERSIONING.md)
compose multiplatform is a different setup to android for this
e
I've just noticed that my ios module doesn't have
build.gradle.kts
file and I did manage to run the app on ios simulator
j
ok, that looks like XCode project.....so you don't have a specific "compose ios" module?
are you pulling in compose code then to SwiftUI iOS project from say
iosMain
code in shared module?
e
hope I got you correctly this is how my ios app gets the code from the shared module (named
composables
)
RootViewController.kt
resides in
composables/src/iosMain/kotlin/com/eladfinish/bible/contest/composables/RootViewController.kt
^
j
ah, ok....so it's probably
build.gradle.kt
in the
composeables
module that you need to update by adding something like following
Copy code
compose {
    kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.8.20")
}
e
Thanks a lot! I managed to run the project on both Android and iOS @John O'Reilly
334 Views