Hello, Just another SwiftExportAction error here. ...
# swift-export
o
Hello, Just another SwiftExportAction error here.
Copy code
Showing All Issues
> A failure occurred while executing org.jetbrains.kotlin.gradle.plugin.mpp.apple.swiftexport.internal.SwiftExportAction

   > Can't translate return type in fun kotlinx.serialization.json.JsonObject.addId(id: kotlin.String): kotlinx.serialization.json.JsonObject: Symbol not found for kotlinx/serialization/json/JsonObject
I'm sorry if this is fixed in newer versions but I couldn't find anything that mentions kotlinx.serialization. And I can't upgrade to 2.2.20 yet. Kotlin version: 2.2.10 Serialization: 1.9.0 Xcode 26 (I guess that could be the problem) I'd appreciate any advice
👍🏻 1
a
Hello there 🙂 For 2.2.10 we do not recommend using Swift Export. While the code is actually there and can run - there are a lot of really meaningful additions made in 2.2.20. One of the main one - is the transitive export, which fixes the problem you are seeing right now. You can probably declare
kotlinx-serialization-json
as exported module, that should help As for xcode 26 part - the first release that supports it is 2.2.21. While the earlier versions should work, there can be bugs and problems. I would recommend using xcode 16.4, if it's not possible to update kotlin at the moment.
o
thank you very much
d
I use 2.2.21 and xcode 26, and my project still had problems when switched to SwiftExport, at this point i'm scary to try it again until it's not fixed.
a
my project still had problems when switched to SwiftExport
What kind of problems?
d
When I changed embedAndSignAppleFrameworkForXcode task to embedSwiftExportForXcode, the project did not build anymore
a
When I changed embedAndSignAppleFrameworkForXcode task to embedSwiftExportForXcode, the project did not build anymore
That can be caused by many reasons, but even when everything is configured correctly and one does not encounter bugs from swift export - out of the box, swift export is not compatible with Objective-C export and requires migration of the codebase (the usage part). So, no, when migrating an existing project to swift export one it's not enough to change the task - one has to also change the usage site. Please see the examples created by the community to get the feel of changes: 1. https://github.com/GuilhE/KMP-ComposeUIViewController/pull/4 2. https://github.com/joreilly/chip-8/commits/main/ - the last 5 commits are related to migration onto swift export If you have encountered a different problem, for example you have discovered a declaration that causes swift export to produce uncompilable code - I am very happy to help with those. Please share a project/reproducer/anything, and we will try and find a way to fix it.
👍🏻 1
👍 1
♥️ 1
g
FWIW in this sample feature-branch, I’m also using coroutines and removed the KMP-NativeCoroutines bridge (still present in main branch)
kodee pleased 1
If anyone needs an advanced example it migh help 😉
check this and this implementations
thank you color 1