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
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