Is there a way to take advantage of Skies generate...
# touchlab-tools
m
Is there a way to take advantage of Skies generated enum as a parameter to a function called by the swift code? I have a pretty deep sealed class hierarchy and a function that takes and instance of the super type which is a little clunky to call from swift so i was trying to make a function that instead takes an instance of the generated enum in
Shared.Skie.Identifiers.MyClass
but those enum cases take an instance of the wrapped sealed type as a parameter whereas i want to be able to call it like
foo(x: .caseA)
t
Unfortunately to get "instance" of Swift's enum with an associated value, you have to provide the value. If I understand correctly, you'd want a separate
enum
, that would describe just the hierarchy without actual class instances, right?
m
Essentially yea. Our hierarchy is pretty nested so in kotlin you can do like
MyClass.InnerA.InnerB.Leaf
and `MyClass.InnerA.InnerB.LeafWithProp("string")`and we got a lot of pushback from the iOS team about the name spacing from the nesting being lost in translation and becoming
MyClassInnerAInnerBLeaf
as well as not being able to get autocomplete with swift enums
.case...
syntax. Right now to appease ios side we basically have a manually maintained wrapper enum written in swift that basically is just a
case myclass_innera_innerb_leaf
that has a property with a big switch on self thats basically
Copy code
var tag: String {
  let wrapped =switch self {
  case myclass_innera_innerb_leaf: MyClassInnerAInnerBLeaf
  ...
  }
  wrapped.tag
}
and i noticed the SKIE generated enum looks pretty similar but isnt hand maintained for every new case.
t
Yeah, that's currently not something SKIE would be able to generate for you. You could write your own SKIE subplugin to generate it, but that's not currently documented (for good reasons 😄 )
m
i was able to get most of the way to the api i wanted while staying all in kotlin and keeping the good autocomplete by writing the wapper enum in kotlin as a sealed class instead of swift and making the names match the underscored names in the swift wrapper, but then we have to add the
.shared
or
()
when calling it and anything that wasnt nested in the base class didnt show up in the the autocomplete after the dot
You could write your own SKIE subplugin
skie felt like magic when i had an early access to it and that hasnt changed lol. Ill leave the wizardry to you for now Tadeas. Thanks for the response!