{"id":13872215,"url":"https://github.com/SwiftJava/swift-android-kotlin","last_synced_at":"2025-07-16T01:33:18.182Z","repository":{"id":146647418,"uuid":"98722409","full_name":"SwiftJava/swift-android-kotlin","owner":"SwiftJava","description":"Kotlin/Swift integration example","archived":false,"fork":false,"pushed_at":"2018-12-20T22:01:03.000Z","size":1234,"stargazers_count":71,"open_issues_count":1,"forks_count":12,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-08-06T23:51:44.240Z","etag":null,"topics":["android-development","opengl-es","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SwiftJava.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-07-29T09:25:20.000Z","updated_at":"2024-07-04T02:13:28.000Z","dependencies_parsed_at":"2023-04-28T20:47:13.666Z","dependency_job_id":null,"html_url":"https://github.com/SwiftJava/swift-android-kotlin","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftJava%2Fswift-android-kotlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftJava%2Fswift-android-kotlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftJava%2Fswift-android-kotlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftJava%2Fswift-android-kotlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SwiftJava","download_url":"https://codeload.github.com/SwiftJava/swift-android-kotlin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226090030,"owners_count":17572114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-development","opengl-es","swift"],"created_at":"2024-08-05T23:00:36.817Z","updated_at":"2024-11-23T19:31:41.458Z","avatar_url":"https://github.com/SwiftJava.png","language":"Swift","readme":"# Kotlin example for the Android Swift toolchain.\n\n![](http://johnholdsworth.com/swiftjava.png?v=1)\n\nAn 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.\n\nRequires a build of the latest Android toolchain downloadable [here](http://johnholdsworth.com/android_toolchain.tgz). 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](https://developer.android.com/studio/index.html). The phone must be api 21 aka Android v5+ aka Lollipop or better (I used an LG K4.)\n\nTo create a new application, decide on a pair of interfaces to connect to and from your Swift\ncode and place them in a [Java Source](https://github.com/SwiftJava/swift-android-kotlin/blob/master/app/src/main/java/com/johnholdsworth/swiftbindings/SwiftHelloBinding.java). Use the command `./genswift.sh` in the [SwiftJava Project](https://github.com/SwiftJava/SwiftJava) to generate Swift (\u0026 Java) sources to include in your application or adapt the [genhello.sh](https://github.com/SwiftJava/SwiftJava/blob/master/genhello.sh) script. Your app's only\n[Package.swift](https://github.com/SwiftJava/swift-android-kotlin/blob/master/app/src/main/swift/Package.swift)\ndependency should be the core JNI interfacing code [java_swift](https://github.com/SwiftJava/java_swift).\n\nThis example is coded to work with version 7 of the toolchain which has some additional requirements\nto work around requirements of the Swift port of Foundation. The cache directory used by web operations\nneeds to be setup in the environment variable \"TMPDIR\". This would usually be the value of\nContext.getCacheDir().getPath() from the java side. In addition, to be able to use SSL you\nneed to add a [CARoot info file](http://curl.haxx.se/docs/caextract.html) to the application's\nraw resources and copy it to this cache directory to be picked up by Foundation as follows:\n\n    setenv(\"URLSessionCertificateAuthorityInfoFile\", cacheDir! + \"/cacert.pem\", 1)\n    setenv(\"TMPDIR\", cacheDir!, 1)\n\nIf you don't want peer validation you have the following option (not recommended at all)\n\n    setenv(\"URLSessionCertificateAuthorityInfoFile\", “INSECURE_SSL_NO_VERIFY”, 1)\n    \n## Simple demo of Swift code accessed over JNI.\n\nTo build, setup the Gradle plugin, then run `./gradlew installDebug`\n\nThis demo is licensed under the Creative Commons CC0 license:\ndo whatever you want.\n\n","funding_links":[],"categories":["Swift"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwiftJava%2Fswift-android-kotlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSwiftJava%2Fswift-android-kotlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwiftJava%2Fswift-android-kotlin/lists"}