https://kotlinlang.org logo
#ios
Title
# ios
m

Marc Reichelt

07/04/2019, 1:30 PM
By the way: The example https://github.com/Kotlin/mpp-example works, but it uses Kotlin 1.3.31 native/multiplatform plugins. It seems the change to 1.3.40 is not trivial, and the build breaks if one tries to simply bump up the version. Did anyone try to get
mpp-example
up and running with Kotlin 1.3.40?
l

louiscad

07/04/2019, 5:19 PM
Kotlin/Native is "moving fast", so there's no binary compatibility guarantees between versions. To use 1.3.40, all dependencies must use it. You should update these if possible
👍 1
m

Marc Reichelt

07/04/2019, 7:30 PM
That’s definitely a good info! But what happens if there are no dependencies as ktor or kotlinx serialization - as in the mpp example?
That would definitely explain why we have such big problems setting up ktor client libs and kotlinx serialization…
l

louiscad

07/04/2019, 8:07 PM
@Marc Reichelt The best way, I don't know. Do you have any iOS developer in your team that would join these 2.5 months? Same question for Android. Do you already know what you want to share between the platforms?
m

Marc Reichelt

07/04/2019, 8:19 PM
Maybe and yes - so we would have an iOS developer on the team, and I could help from the Android side. The research is mostly driven by a student. It would not be used in production because the features are not stable enough yet - but we want to look how we can improve our current and future projects by starting to share code, and move to a shared code basis as soon as it’s stable enough. As for code sharing: we want to focus on some business logic - mostly JSON serialization and API calls, but also some data classes / common utility functions. So no code sharing for UI logic planned at the moment.
r

russhwolf

07/04/2019, 9:09 PM
What wasn’t working for you in that sample? (It’s now been updated to 1.3.41 BTW). Seems to build fine for me on both platforms.
The one thing I see not working is the iosTest gradle task, which needs a couple small updates
Try this if you want to get it running
Copy code
task iosTest {
    def device = project.findProperty("iosDevice")?.toString() ?: "iPhone 8"
    dependsOn 'linkDebugTestIos'
    group = JavaBasePlugin.VERIFICATION_GROUP
    description = "Runs tests for target 'ios' on an iOS simulator"

    doLast {
        def binary = kotlin.targets.ios.binaries.getTest('DEBUG').outputFile
        exec {
            commandLine 'xcrun', 'simctl', 'spawn', device, binary.absolutePath
        }
    }
}
To your more general question, it’s early to be using this stuff but it’s definitely possible. You do need to be prepared for some unexpected hiccups, and you have to be careful to make sure your versions are all synced to get the native side working. Focusing on API calls, serialization, and logic-layer utilities is a good approach
👍 2