All Projects → SwiftJava → swift-android-kotlin

SwiftJava / swift-android-kotlin

Licence: other
Kotlin/Swift integration example

Programming Languages

swift
15916 projects
java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to swift-android-kotlin

VideoPreLoading
Demo for video PreLoading/ PreCaching using ExoPlayer 2.13.3 in Android.
Stars: ✭ 61 (-11.59%)
Mutual labels:  android-development
topologic
Visualiser for basic geometric primitives and fractals in arbitrary-dimensional spaces
Stars: ✭ 39 (-43.48%)
Mutual labels:  opengl-es
Myapplications
My Tutorials
Stars: ✭ 50 (-27.54%)
Mutual labels:  android-development
lvg
Lion Vector Graphics
Stars: ✭ 106 (+53.62%)
Mutual labels:  opengl-es
ValidUtil
No description or website provided.
Stars: ✭ 23 (-66.67%)
Mutual labels:  android-development
antimalwareapp
Anti-malware for Android using machine learning
Stars: ✭ 206 (+198.55%)
Mutual labels:  android-development
VSpot
A nice focus view intro for your app. Focus a specific view on first time launch
Stars: ✭ 27 (-60.87%)
Mutual labels:  android-development
Multi-Module-Nextflix-Composable
Includes jetpack compose, navigation, paging, hilt, retrofit, coil, coroutines, flow..
Stars: ✭ 195 (+182.61%)
Mutual labels:  android-development
Age-Gender Estimation TF-Android
Age + Gender Estimation on Android with TensorFlow Lite
Stars: ✭ 34 (-50.72%)
Mutual labels:  android-development
RN Android Native
Sample for React Native Android UI
Stars: ✭ 19 (-72.46%)
Mutual labels:  android-development
github-commit-browser
A blog companion sample project that demonstrates saving UI state after process death on Android utilizing the community established 3rd party libraries
Stars: ✭ 55 (-20.29%)
Mutual labels:  android-development
CircularDialogs
Android dialog library to give user feedback about the common operations like Success, Warning and Errors.
Stars: ✭ 35 (-49.28%)
Mutual labels:  android-development
ApkSize-Analyzer
An Apk analyzer with CI/CD support and multiple reports in HTML, PDF, JSON
Stars: ✭ 19 (-72.46%)
Mutual labels:  android-development
magnum-extras
Extras for the Magnum C++11/C++14 graphics engine
Stars: ✭ 26 (-62.32%)
Mutual labels:  opengl-es
Kata-Dagger2-Android
Kata to practice Dependency injection using Dagger 2.
Stars: ✭ 21 (-69.57%)
Mutual labels:  android-development
codee-app
Android IDE for programming fully written on Kotlin
Stars: ✭ 42 (-39.13%)
Mutual labels:  android-development
buildAPKsApps
Android APK app sources that build in Termux on Amazon Fire, Android and Chromebook! https://sdrausty.github.io/buildAPKsApps/
Stars: ✭ 32 (-53.62%)
Mutual labels:  android-development
PowerPreference
💾 A Powerful library to control and simplify the usage of shared preference in Android.
Stars: ✭ 95 (+37.68%)
Mutual labels:  android-development
snippet-timekeeper
An android library to measure code execution time. No need to remove the measurement code, automatically becomes no-op in the release variants. Does not compromise with the code readability and comes with features that enhance the developer experience.
Stars: ✭ 70 (+1.45%)
Mutual labels:  android-development
ChipView
A simple Chip based EditText with a searchable ListView
Stars: ✭ 44 (-36.23%)
Mutual labels:  android-development

Kotlin example for the Android Swift toolchain.

An example application for mixing Swift and Kotlin in an Android application. This allows you to reuse model layer code from your iOS application when porting to Android. The "binding" between the Kotlin or Java code and Swift is completely type safe with all JNI code automatically generated using a script. Building the Swift code is performed using the Swift Package manager and a small gradle plugin.

Requires a build of the latest Android toolchain downloadable here. Once you've extracted the toolchain, run swift-install/setup.sh to get started and install the gradle plugin. You then run ./gradlew installDebug or build the project in Android Studio. Make sure the that the ANDROID_HOME environment variable is set to the path to an Android SDK. The phone must be api 21 aka Android v5+ aka Lollipop or better (I used an LG K4.)

To create a new application, decide on a pair of interfaces to connect to and from your Swift code and place them in a Java Source. Use the command ./genswift.sh in the SwiftJava Project to generate Swift (& Java) sources to include in your application or adapt the genhello.sh script. Your app's only Package.swift dependency should be the core JNI interfacing code java_swift.

This example is coded to work with version 7 of the toolchain which has some additional requirements to work around requirements of the Swift port of Foundation. The cache directory used by web operations needs to be setup in the environment variable "TMPDIR". This would usually be the value of Context.getCacheDir().getPath() from the java side. In addition, to be able to use SSL you need to add a CARoot info file to the application's raw resources and copy it to this cache directory to be picked up by Foundation as follows:

setenv("URLSessionCertificateAuthorityInfoFile", cacheDir! + "/cacert.pem", 1)
setenv("TMPDIR", cacheDir!, 1)

If you don't want peer validation you have the following option (not recommended at all)

setenv("URLSessionCertificateAuthorityInfoFile", “INSECURE_SSL_NO_VERIFY”, 1)

Simple demo of Swift code accessed over JNI.

To build, setup the Gradle plugin, then run ./gradlew installDebug

This demo is licensed under the Creative Commons CC0 license: do whatever you want.

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].