I am seeing some weird behavior when producing an ...
# kotlin-native
s
I am seeing some weird behavior when producing an obj-c framework and using it in Swift. My framework
A
has a dependency
B
that is another Kotlin library that it brings in through gradle via a maven repo. In
B
I have a class that is structured like this:
Copy code
open class Fail(val code: IFailCode = CODE.ERROR_404) {

    enum class CODE(override val description: String, override val code: Int) : IFailCode {
        ERROR_404("Resource could not be found", 404),
        …
    }
    
    interface IFailCode {
        val code: Int
        val description: String
    }
}
The weird thing is that when I use the generated framework from
A
in a Swift app, I can access
Fail
and
IFailCode
, but not the enum class
CODE
. Also of note, they are named
BFail
and
BFailIFailCode
. Following this pattern I would expect
CODE
to be accessible as
BFailCODE
but it is not. Why wouldn’t I be able to access
CODE
from Swift when I can access
Fail
and
IFailCode
? The only difference I see is that one is an enum while the other two are a class and an interface. Do these behave differently when converted to objc framework?
k
have you looked at the generated Obj-C header from Xcode?
s
Yeah,
CODE
or any renaming of it isn’t in there
k
interesting
it's weird that the interop docs don't mention enum anywhere
s
I know enums can be exported because I have other enums defined in my framework that work fine. But this enum that comes from a dependency of my framework isn’t showing up
k
ahhh
s
maybe
enum
doesn’t show up in those docs because it is covered under
class
?
k
is it an
api
dependency, and are you exporting it?
s
what do you mean by
api
dependency?
k
in the gradle file, instead of
implementation
s
oh
lemme check
pretty sure it’s
implementation
yep, implementation
Exporting dependencies in frameworks
s
I don’t want to export all classes from my dependency
Just certain ones
k
i'm afraid it doesn't work that way
s
I mean, it currently is working
k
perhaps you can trick it by using the symbols you need from B within A
s
My framework
A
depends on
B
where
Fail
and
IFailCode
are defined
And I can access both from my Swift application
Yes, I think that’s what it is
Because I include
Fail
in the function signature of some of my public methods of
A