All Projects → Albert-Gao → kotlin-native-mobile-multiplatform-example

Albert-Gao / kotlin-native-mobile-multiplatform-example

Licence: other
Code sharing between iOS and Android with Kotlin native

Programming Languages

swift
15916 projects
kotlin
9241 projects

Projects that are alternatives of or similar to kotlin-native-mobile-multiplatform-example

Biometric-Authentication-Android
A sample implementation of AndroidX biometrics API using Kotlin. Authenticate using biometrics or PIN/Password if biometrics isn't available on device. Fully implemented in Jetpack compose using Material 3 dynamic theming and also has a separate implementation in xml with MDC 3.
Stars: ✭ 29 (-44.23%)
Mutual labels:  native, android-studio
Android-WebView-in-Kotlin
Native Android WebView Example in Kotlin. Website to android app github open source template.
Stars: ✭ 87 (+67.31%)
Mutual labels:  native, android-studio
ti.playservices
Titanium module for Google Play Services
Stars: ✭ 19 (-63.46%)
Mutual labels:  native
parcl
Gradle plugin for bundling your Java application for distribution on Windows, Mac and Linux
Stars: ✭ 52 (+0%)
Mutual labels:  native
interstellar
Dark editor theme for JetBrains IDEs
Stars: ✭ 26 (-50%)
Mutual labels:  android-studio
Rainbow-Wifi-Hack-Utility-Android
The program implements brute Wi-Fi network method on platform Android
Stars: ✭ 39 (-25%)
Mutual labels:  android-studio
ScreenKap
A simple screen recorder app for Android
Stars: ✭ 46 (-11.54%)
Mutual labels:  android-studio
tools-sample
Collection of examples on how to improve preview of your layout
Stars: ✭ 20 (-61.54%)
Mutual labels:  android-studio
Little-Ruler
A game engine that can be built for Android and Windows.
Stars: ✭ 16 (-69.23%)
Mutual labels:  android-studio
Skill-learn-collect
Collection of relating to skills
Stars: ✭ 109 (+109.62%)
Mutual labels:  android-studio
generator-omaha
Yeoman generator designed to help you craft sustainable code for the modern web
Stars: ✭ 12 (-76.92%)
Mutual labels:  native
testWeChat
这是一个可以自动发送微信消息以及朋友圈的小工具
Stars: ✭ 51 (-1.92%)
Mutual labels:  android-studio
LiveData-DataBinding-Kotlin
Sample to practice LiveData + DataBinding
Stars: ✭ 89 (+71.15%)
Mutual labels:  android-studio
HouseAds2
A library ( V2 ) for cross promoting own apps within own apps - for Android
Stars: ✭ 23 (-55.77%)
Mutual labels:  android-studio
Take-Notes
Huge Assignments to Write with only a little time in Hand?
Stars: ✭ 17 (-67.31%)
Mutual labels:  android-studio
Litrato
Android photo editing app with various filters and tools. Included advanced features like masking, histogram, color picker, EXIF viewer...
Stars: ✭ 54 (+3.85%)
Mutual labels:  android-studio
imgui-java
JNI based binding for Dear ImGui
Stars: ✭ 270 (+419.23%)
Mutual labels:  native
Vuforia-Samples-Android-Studio
This is a Vuforia Samples App for Android Studio.
Stars: ✭ 25 (-51.92%)
Mutual labels:  android-studio
Android-daily-read-tips
log for articles and info in android for every developer
Stars: ✭ 13 (-75%)
Mutual labels:  android-studio
native-java-examples
Native Java Apps with Micronaut, Quarkus, and Spring Boot
Stars: ✭ 44 (-15.38%)
Mutual labels:  native

Kotlin Native mobile multiplatform example

There is a cross more platforms version (added JVM and JS) in this repo

Read my blog if you want more details:

Overview

This is an example of using Kotlin native to share the code between iOS and Android. It contains the tests for all the platform code. Setup via the support from multiplatform kotlin.

This setup is aiming to solve the problem, where we want to write the platform specific code in a multiplatform manner.

Folders

  • android: Android project built by Android Studio
  • ios: iOS Project built by XCode
  • common: Kotlin code that is meant to be across platform across all platforms without any change.
  • platforms: platform specific API which will then be compiled with common
    • android: Some platform specific code for android, which will be included in the android folder
    • ios: Some platform specific code for iOS, it will be compiled as an iOS framework

Workflow:

  • Work on Android App: Open android folder in Android Studio
  • Work on iOS App: Open ios folder in XCode
  • Work on sharing code: Open the root folder in IDEA or any other IDE.

In fact, you can edit the sharing code in android studio as well, as we embed them as module, and they all use the same language.

About the example

  • Sample class is for code that is sharing across platforms (Which means you only use API from kotlin-stdlib-common or some other cross platform lib).

  • Platform class is a class which has been implemented twice for different platforms for showing the platform API case.

  • Open android folder from the root in Android Studio, run the app, it will show a string from the :platforms-android

  • Open ios folder from the root in XCode, run the app, it will show a string from the :platforms-ios

  • And the string is from both platforms are retrieved from the Sample class.

Tips

If you think the XCode building phase is slow. That is because it will build the KN generated iOS framework every time. You can modify it by just copying the framework files without building it. Because you can always edit Kotlin native code somewhere else.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].