Skip to content
This repository has been archived by the owner on Aug 8, 2019. It is now read-only.

A Kotlin/Native sample project with interoperability between Swift and Kotlin

Notifications You must be signed in to change notification settings

p-l/kotlin-native-experiment

Repository files navigation

iOS & Android Kotlin/Native boilerplate project

Sharing code between multiple platform is what every multi-plateform framework tries to do. Strking the right balance between shared code and native components and performance is what everyone struggles with. The approach in this sample project is to have the logic driving the applications is written in Kotlin and shared with both platforms and UI and platform specific behaviour (e.g. threading, networking, gps) are implemented with native API and language.

Project Sutructure

android/src : Android specific code core/src/androidMain : Android specific implementation of core methods core/src/iosMain : iOS specific implementation of core methods core/src/commonsMain : Multi-platform code core/build/xcode-framrworks: Where the ios Framework resides ios/src : iOS specific source code

Build the Android application

Start Android Studio and open the root of this project. It'll include the core and the android project. You're ready to hit build.

Buld the iOS application

Go to the ios folder. Run pod install to install dependancies. Open Xcode and open the ios.xcworkspace. You're ready to hit build.

Working with Kotlin/Native

Debuging Kotlin code within iOS project

You'll need AppCode 2018.2 not the current 2018.3 as the Kotlin/Native plugin isn't compatible with 2018.3 at the moment of this writing (2018-12-09).

If you have the proper version of AppCode and the Kotlin/Native plugin you can place a breakpoint like in any Swift class.

Swift -> Kotlin objects

Any swift class that interacts with Kotlin core needs to implement NSObject. Without this, you'll run into toKotlin method errors at runtime. The error will look something like what's bellow:

*** NSForwarding: warning: object 0x600001ee5b90 of class 'ios.HttpClient' does not implement methodSignatureForSelector: -- trouble ahead
Unrecognized selector -[app.SwiftClass toKotlin:]

Renaming the application

TBC

About

A Kotlin/Native sample project with interoperability between Swift and Kotlin

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published