Hi, are we able to export modules with compose cod...
# swift-export
a
Hi, are we able to export modules with compose code inside of them using swift export? I am trying to achieve this after looking around in slack if I am not mistaken we are not able to do this?
a
modules with compose code inside of them using swift export
Would you mind elaborating, what are you trying to export? can you demonstrate a declaration we are talking about?
a
I was trying to export the template with composeApp (the one with shared ui)
using swift export
the shared ui using CMP from KMP Wizard
a
That's great to hear! How did it go? 🙂
a
I configured the composeApp with swift export, also i switched the kotlin compile task in xcode to composeAppembedSwiftExportForXcode
But it doest build
a
Do you have an error to demonstrate?
a
Command PhaseScriptExecution failed with a nonzero exit code
âž• 1
this is kotlin = "2.2.20-RC2"
a
That's not an error. Please open xcode build logs (left panel, top, the most right button), select failed build and copy the actual error
a
Cannot locate tasks that match 'composeAppembedSwiftExportForXcode' as task 'embedSwiftExportForXcode' not found in project ':composeApp'.
i think it should be this
image.png
g
I can run with Kotlin 2.3.0-dev versions, but I found a runtime error regarding shared resources
a
For me it happens in both Xcode and IntelliJ
Xcode is a terrible piece of software
cant even get a proper error over there
@Guilherme Delgado regarding my original question, we can run swift export along side common compose code right?
g
yes, so far I could run simple things
(didn’t test more robust projects, the ones I have, share resources)
a
I have created a new project from the wizard and configured it with swift export. It is buildable. So, you have misconfigured something. I'm attaching the patch, containing the configuration of that project. Please inspect it and find the error in your configuration. When you do find the error - please report back, it will help us improve the DX of swift export! Thanks! @Guilherme Delgado is right, and that project, while buildable, is not runnable.
👍 1
a
I will try again thank you
I think it did not like me upgrading the compose version to anything above composeMultiplatform = "1.8.2"
it seems to fail if i upgrade compose
It works, and it crashes but i think it is related to the issue mentioned above about resources. Thanks guys
g
> I think it did not like me upgrading the compose version to anything above composeMultiplatform = “1.8.2” FWIW, I have no problems using, for instance:
Copy code
kotlin = "2.3.0-dev-4778"
ksp = "2.2.20-RC-2.0.2"
kotlinCompose = "1.9.0-beta03"
kotlinxSerialization = "1.9.0"
kotlinxSerializationPlugin = "2.2.20-RC"
a
@Artem Olkov, sorry Now that im taking a better look at the git diff file, there is no mention of this block, with this it still fails for me
i applied the diff with junie on an empty template
Now im a bit confused
a
Now im a bit confused
With what?
a
If we arent using this swift export block, but changing the task to the swift export on ios side
are we still exporting swift code this way
a
swift export block in DSL provides a way to configure a task, but the actual task is created by default out of the box. If there is no need for configuration - this block can be omitted.
👍 1
a
Ah I see, alright perfect then, thanks for your time
g
If you use gradle convention plugins, you can test it just by:
Copy code
public class SomePlugin : Plugin<Project> {
   override fun apply(project: Project) {
       val kmp = extensions.getByType(KotlinMultiplatformExtension::class.java)
       val swiftExport = kmp.extensions.getByType(SwiftExportExtension::class.java)
…
}
swiftExport will always be found
👍 1
d
I have the same error: Command PhaseScriptExecution failed with a nonzero exit code However it's not locally, but in the Xcode Cloud, I suppose it's not supported to build a KMP ios target project there I verified the logs:
a
d
Thanks @Artem Olkov
c
Artem, have you tried building with Java 25 and a recent Gradle 9 version? I’m curious if there’s an example of a project that successfully builds an Xcode Cloud using the latest tools. We’re having an issue in another thread with Maven package downloads https://kotlinlang.slack.com/archives/C0346LWVBJ4/p1735133830361459
a
It does build
c
Arsildo what Java, Gradle, and Kotlin version? I’m trying to narrow down if there’s other variables at play.
a
Yes, sorry, I am testing on the bleeding edge with these versions here
Copy code
compose-multiplatform = "1.12.0-alpha01+dev4104"
agp = "9.0.0-alpha06"
kotlin = "2.4.0-RC-185"
androidx-lifecycle = "2.11.10-alpha01+dev4104"
androidx-navigation3 = "1.1.10-alpha01+dev4104"
Swift export enabled and running great.
c
Gradle version? JVM version?
a
agp 9, jvm 17
c
What about Gradle in gradle/wapper/gradle.properties
a
Copy code
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
Copy code
#Kotlin
kotlin.code.style=official
kotlin.daemon.jvmargs=-Xmx4G

#Gradle
org.gradle.jvmargs=-Xmx4G -Dfile.encoding=UTF-8
org.gradle.configuration-cache=true
org.gradle.caching=true

#Android
android.nonTransitiveRClass=true
android.useAndroidX=true
c
OK perfect. So the main difference I see is that you’re using Java 17 and I’m using Java 25.0.3 (Adoptium).
a
I am pretty sure i should work with jvm 25 as well
what error are you running into?
c
Linked in the other thread—Maven Central artifact downloads say “connection reset by peer.” Only workaround I’ve been able to find is a strange set of gradle properties to disable both parallel and IPv6.
I had a theory about rate limiting or WAF on Maven Central if Xcode Cloud has a small number of outbound IPs but setting up my own Maven proxy in Google Cloud still got the same error.
a
Copy code
# JetBrains Lifecycle
androidx-lifecycleViewmodelCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" }
androidx-lifecycleRuntimeCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }
androidx-lifecycleViewmodelNavigation3 = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-navigation3", version.ref = "androidx-lifecycle" }
androidx-savedstate-compose = { module = "org.jetbrains.androidx.savedstate:savedstate-compose", version.ref = "androidx-savedstate" }
pull the jetbrains versions instead.
c
The build works fine locally on my Mac and in GitHub Actions—I don’t think its compose multiplatform dependencies.
a
Ah, i see, then not sure how i can help further
c
If you have time, would you be able to see if Java 25 still works in your project when built on Xcode Cloud?
I’m also going to see if I can downgrade, although that may be a bit of a project.