By the popular request Kotlin/Native team has designed and implemented facility for extending existing Objective-C and Swift applications with frameworks written in Kotlin/Native. It allows one to create framework from portable part of the project, written in Kotlin (i.e. shared on iOS and Android, for example) and import it to an existing application written in Objective-C or Swift, as a regular framework. As an example of such functionality, we have developed basic calculator application, see https://github.com/JetBrains/kotlin-native/tree/master/samples/calculator. It consists of Swift UI and Kotlin “business logic” of the calculator, capable to parse arithmetic expression and evaluate them. Important Kotlin types, such as kotlin.String, kotlin.List, kotlin.Number and function types are transparently mapped to NSString, NSArray, NSNumber and block pointers in the Objective-C world. Kotlin classes and interfaces can be inherited by Objective-C classes.
Please try this feature (available in master of https://github.com/JetBrains/kotlin-native) and let us know of your experience, send us your curses and praises. It will be available as part of upcoming 0.5 release of Kotlin/Native.
👍 16
🎉 27
g
gildor
12/07/2017, 7:43 AM
Great news!
Such use case is can be practically useful for many projects including our own.
Really impressed with progress of ObjC support
But I have a question about example.
I have an error when try to build calculator example:
Task compileKonanKotlinArithmeticParser failed with NullPointerException.