Okay, i see. If you could not access some class from swift, it means it wasn’t propagated into framework header file. It could be done it 2 ways: tell compile to import all classes from particular module or do simple hack (pit it somewhere inside iosMain module on
Kotlin side)
fun Either.Value<*>.foo() {}
fun Either.Error<*>.foo() {}
fun Either<*>.foo() {}
After that it just a technical question how you want to handle it is
Swift:
func handle<ValueType>(result: Either<ValueType>) {
switch either {
case let value as EitherValue<ValueType>:
print(value.value!)
case let error as EitherError<ValueType>:
print(error.message)
default:
fatalError("Unexpected type")
}
}
Note that Either type can be named a bit differently after KMM interop. In our case it called
Platform_apiEither<T>
and
Platform_apiEitherValue<ValueType>
and
Platform_apiEitherError<ValueType>