img

Droidcon NYC, on iOS, with Kotlin Native

(Crosspost from medium.com/@kpgalligan)

I don’t want to lead you on too much about the status of coding Kotlin on iOS. I’m very excited about where that’s going, but it’ll be a little while.

The Kotlin team is making tons of progress, though. It’s coming and it’ll be pretty great.

One of the things that will be needed are Kotlin libraries that don’t need access to the JRE. A lot of stuff is in the JRE, so many libraries will have some issues.

I’m not sure running Doppl/J2objc under Kotlin native will be how a lot of apps are built, but I was curious to see if it would work. After all, J2objc is basically a JRE running on iOS. With some smoothing, I think the two will go together quite well.

The Doppl Droidcon app runs RxJava 2, Retrofit 2, Dagger, Android Architecture components (RC1), with room, all on iOS, with Swift as a front end.

Here’s a Kotlin native version, calling into the same Doppl code underneath (RxJava 2, etc). It’s only the main schedule page. There are technical hurdles on the Kotlin side that I won’t go into, and I think they’re a mix of things the Kotlin team is fixing and/or me not fully understanding how to interact with the framework (and not wanting to spend more than a few hours on a proof of concept).

Get the Droidconsample branch. You’ll need to run through the Kotlin Native setup instructions. You’ll also need Doppl functional. Run through the new and improved Tutorial.

Replace the Doppl dist dir in a couple places:

samples/uikit/src/main/c_interop/objc.def

and…

samples/uikit/build.gradle

Then run

./gradlew uikit:build

and finally

./gradlew -p uikit compileKonanApp

That’ll take a while.

Then open the ‘konan.xcodeproj’ project and run. You’ll need an actual device, not a simulator.

If you do everything right, you’ll get an unstyled schedule list app for an old conference, but still, it works!

See you at KotlinConf and Droidcon SF!