s

    Sam

    3 months ago
    Does anyone have any tips for mocking classes defined in Kotlin from Swift? Context being that I'm writing a Swift class that takes a Kotlin dependency. This works perfectly in production but in tests I'd like to be able to mock out that kotlin dependency
    m

    Michal Klimczak

    3 months ago
    you can declare an interface for that class in kotlin. it will become a swift protocol. and then you can use that protocol for ios mock / fake
    s

    Sam

    3 months ago
    Yeah that's what I've done but can't find a mocking framework that will auto-generate the mock, do you have any examples?
    m

    Michal Klimczak

    3 months ago
    that's a general pain point with ios development, not related to kotlin native. afaik there's no mockk-like stuff, because swift doesn't fully support reflection
    theoretically these are obj-c classes so they could be mocked... but I don't think anyone created such a framework, because there wouldn't be much of a market for it
    s

    Sam

    3 months ago
    There's a few decent swift mocking libraries these days, mockingbird for example, (though like you said they work off a different principle to most due to the lack of reflection) My question was more whether someone had created a framework that allows for mocking the classes defined in Kotlin