Hi folks, I have a external dependency (maven depe...
# multiplatform
s
Hi folks, I have a external dependency (maven dependency) that has
sealed class
, on my commonMain I have a public API function that will be called directly from Swift that uses sealed class type from this library, It looks like that Kotlin Native is only generating Header for the
sealed class Type
and not it children classes. This is a know issue? there is any workaround for this?
s
s
I don’t if this could fit my case because the sealed class is in a thrid party library
s
It works with 3rd party libs as well by default It scans all sealed classes that are a part of your project (even if they're coming from a library)
s
Oh that is awesome, I will try that
I seems to be a bug that the Objc Header generation does not go though all Sealed class children when some function function has a the root sealed class type
So apparently KSwift is dependent on Cocoapods? we are not using cocoapods, we are build xcframework and importing in the iOS app
u
s
The issue is that the project is not a monorepo currently, so the iOS project uses XCFramework that is published in a git repositorio only for packaging for KMM. What I’m thinking that could be possible is: In the GH Action that publishes the XCFramework, also, publish the Swifit files and make iOS project consume both, XCFramework and Swift files.
Does KSwift work with the new Kotlin Native artifact system? My module that export XCFramework only have the Artifact setup with all modules dependencies being at
setModules
. There is any task that can trigger the code generation? `assembleKmmXCFramework`is not triggering for me
m
Are you exporting the third party library when you build your framework? By default the Objective-C header for your framework will only contain the class from third party libraries that you use directly in your API. I'm guessing you have a function that takes the sealed class and you use the children inside the function. If that is the case, you probably have to export the library, but that will export everything in the library.
s
Exacly, but this does not seem right, sealed class is more like enum, I don’t get why the OBJC header is not exporting all it children because if you are using the root sealed class as parameter you expect that you will pass as parameter one of it children
m
You could say the same of all abstract classes. I agree that you normally probably want that, but it could also be that you have functions that return the sealed class and the Swift code never needs to known about specific children. The exporter just doesn't know enough and there's not enough tooling for you to customize (would be nice to selectively pick what symbols get exported). I haven't played with the KSwift stuff, and if it solves your problem then that works.
s
Yes I could say, but this is the use case for sealed classes, you know at compile time all it subclass, so when you ask for some type, you have a limited options that the Compiler knows, so, why not export it to objc header.
KSwift I don’t thing would solve this problem, unless it also generate kotlin code that uses all the children from a Sealed class of third party library.
h
are you adding your missing dependency as an
api
in gradle?
s
There is no missing dependency, only missing couple reference from Sealed class children in the objc header and yes, everything that should be
api
is API