From 9b9e661bc425320098c9b6410c38c67fc1f564df Mon Sep 17 00:00:00 2001 From: Konrad Malawski Date: Tue, 28 Oct 2025 09:14:37 +0900 Subject: [PATCH 01/16] Reorganize example names Based on public reception, people were immediately opening up the "simplest name" looking one, and then taken aback by the low-level JNI bridging full of unsafe code and cdecl etc. We should make it clear that those examples are just that: low level and raw jni examples, as compared to other ones using swift-java interop. It should be easier to discover the swift-java example, because that provides a better first impression, and long term user experience. --- README.md | 11 ++++++---- .../.gitignore | 0 .../README.md | 7 +++--- .../hashing-app}/.gitignore | 0 .../hashing-app/build.gradle.kts | 3 +-- .../hashing-app/proguard-rules.pro | 0 .../hashingapp/ExampleInstrumentedTest.kt | 0 .../hashing-app/src/main/AndroidManifest.xml | 0 .../com/example/hashingapp/MainActivity.kt | 0 .../com/example/hashingapp/ui/theme/Color.kt | 0 .../com/example/hashingapp/ui/theme/Theme.kt | 0 .../com/example/hashingapp/ui/theme/Type.kt | 0 .../res/drawable/ic_launcher_background.xml | 0 .../res/drawable/ic_launcher_foreground.xml | 0 .../main/res/mipmap-anydpi/ic_launcher.xml | 0 .../res/mipmap-anydpi/ic_launcher_round.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin .../res/mipmap-hdpi/ic_launcher_round.webp | Bin .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin .../res/mipmap-mdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin .../src/main/res/values/colors.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/themes.xml | 0 .../src/main/res/xml/backup_rules.xml | 0 .../main/res/xml/data_extraction_rules.xml | 0 .../com/example/hashingapp/ExampleUnitTest.kt | 0 .../hashing-lib/Package.swift | 0 .../Sources/SwiftHashing/SwiftHashing.swift | 0 .../Sources/SwiftHashing/swift-java.config | 0 .../SwiftHashingTests/SwiftHashingTests.swift | 0 .../hashing-lib/build.gradle | 0 .../hashing-lib/gradle.properties | 0 .../resources/ide.png | Bin .../.gitignore | 0 .../README.md | 10 ++++----- .../build.gradle.kts | 0 .../screenshot.png | Bin .../src/main/AndroidManifest.xml | 0 .../org/example/helloswift/MainActivity.kt | 4 ++-- .../res/drawable/ic_launcher_background.xml | 0 .../res/drawable/ic_launcher_foreground.xml | 0 .../src/main/res/layout/activity_main.xml | 0 .../main/res/mipmap-anydpi/ic_launcher.xml | 0 .../res/mipmap-anydpi/ic_launcher_round.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin .../res/mipmap-hdpi/ic_launcher_round.webp | Bin .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin .../res/mipmap-mdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin .../src/main/res/values-night/themes.xml | 0 .../src/main/res/values/colors.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/themes.xml | 0 .../src/main/res/xml/backup_rules.xml | 0 .../main/res/xml/data_extraction_rules.xml | 0 .../src/main/swift/.gitignore | 0 .../src/main/swift/Package.swift | 6 +++--- .../hello-swift-callback.swift | 2 +- .../.gitignore | 0 .../README.md | 12 +++++------ .../build.gradle.kts | 0 .../example/swiftlibrary/SwiftLibraryTest.kt | 0 .../src/main/AndroidManifest.xml | 0 .../org/example/swiftlibrary/SwiftLibrary.kt | 2 +- .../src/main/swift/.gitignore | 0 .../src/main/swift/Package.swift | 6 +++--- .../swift/Sources/helloswift/helloswift.swift | 0 .../.gitignore | 0 .../README.md | 8 +++---- .../build.gradle.kts | 0 .../screenshot.png | Bin .../src/main/AndroidManifest.xml | 0 .../org/example/helloswift/MainActivity.kt | 0 .../res/drawable/ic_launcher_background.xml | 0 .../res/drawable/ic_launcher_foreground.xml | 0 .../src/main/res/layout/activity_main.xml | 0 .../main/res/mipmap-anydpi/ic_launcher.xml | 0 .../res/mipmap-anydpi/ic_launcher_round.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin .../res/mipmap-hdpi/ic_launcher_round.webp | Bin .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin .../res/mipmap-mdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin .../src/main/res/values-night/themes.xml | 0 .../src/main/res/values/colors.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/themes.xml | 0 .../src/main/res/xml/backup_rules.xml | 0 .../main/res/xml/data_extraction_rules.xml | 0 .../src/main/swift/.gitignore | 0 .../src/main/swift/Package.swift | 0 .../swift/Sources/helloswift/helloswift.swift | 0 settings.gradle.kts | 20 ++++++++++++------ 109 files changed, 49 insertions(+), 42 deletions(-) rename {swift-java-hashing-example => hello-swift-java}/.gitignore (100%) rename {swift-java-hashing-example => hello-swift-java}/README.md (92%) rename {hello-swift-callback => hello-swift-java/hashing-app}/.gitignore (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-app/build.gradle.kts (96%) rename {swift-java-hashing-example => hello-swift-java}/hashing-app/proguard-rules.pro (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-app/src/androidTest/java/com/example/hashingapp/ExampleInstrumentedTest.kt (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-app/src/main/AndroidManifest.xml (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-app/src/main/java/com/example/hashingapp/MainActivity.kt (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Color.kt (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Theme.kt (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Type.kt (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/drawable/ic_launcher_background.xml (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/drawable/ic_launcher_foreground.xml (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/mipmap-anydpi/ic_launcher.xml (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/mipmap-anydpi/ic_launcher_round.xml (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/mipmap-hdpi/ic_launcher.webp (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/mipmap-hdpi/ic_launcher_round.webp (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/mipmap-mdpi/ic_launcher.webp (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/mipmap-mdpi/ic_launcher_round.webp (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/mipmap-xhdpi/ic_launcher.webp (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/mipmap-xhdpi/ic_launcher_round.webp (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/mipmap-xxhdpi/ic_launcher.webp (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/mipmap-xxxhdpi/ic_launcher.webp (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/values/colors.xml (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-app/src/main/res/values/strings.xml (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-app/src/main/res/values/themes.xml (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/xml/backup_rules.xml (100%) rename {hello-swift-callback => hello-swift-java/hashing-app}/src/main/res/xml/data_extraction_rules.xml (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-app/src/test/java/com/example/hashingapp/ExampleUnitTest.kt (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-lib/Package.swift (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-lib/Sources/SwiftHashing/SwiftHashing.swift (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-lib/Sources/SwiftHashing/swift-java.config (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-lib/Tests/SwiftHashingTests/SwiftHashingTests.swift (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-lib/build.gradle (100%) rename {swift-java-hashing-example => hello-swift-java}/hashing-lib/gradle.properties (100%) rename {swift-java-hashing-example => hello-swift-java}/resources/ide.png (100%) rename {hello-swift-library => hello-swift-raw-jni-callback}/.gitignore (100%) rename {hello-swift-callback => hello-swift-raw-jni-callback}/README.md (72%) rename {hello-swift-callback => hello-swift-raw-jni-callback}/build.gradle.kts (100%) rename {hello-swift-callback => hello-swift-raw-jni-callback}/screenshot.png (100%) rename {hello-swift-callback => hello-swift-raw-jni-callback}/src/main/AndroidManifest.xml (100%) rename {hello-swift-callback => hello-swift-raw-jni-callback}/src/main/java/org/example/helloswift/MainActivity.kt (92%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/drawable/ic_launcher_background.xml (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/drawable/ic_launcher_foreground.xml (100%) rename {hello-swift-callback => hello-swift-raw-jni-callback}/src/main/res/layout/activity_main.xml (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/mipmap-anydpi/ic_launcher.xml (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/mipmap-anydpi/ic_launcher_round.xml (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/mipmap-hdpi/ic_launcher.webp (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/mipmap-hdpi/ic_launcher_round.webp (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/mipmap-mdpi/ic_launcher.webp (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/mipmap-mdpi/ic_launcher_round.webp (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/mipmap-xhdpi/ic_launcher.webp (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/mipmap-xhdpi/ic_launcher_round.webp (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/mipmap-xxhdpi/ic_launcher.webp (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/mipmap-xxxhdpi/ic_launcher.webp (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp (100%) rename {hello-swift-callback => hello-swift-raw-jni-callback}/src/main/res/values-night/themes.xml (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/values/colors.xml (100%) rename {hello-swift-callback => hello-swift-raw-jni-callback}/src/main/res/values/strings.xml (100%) rename {hello-swift-callback => hello-swift-raw-jni-callback}/src/main/res/values/themes.xml (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/xml/backup_rules.xml (100%) rename {hello-swift => hello-swift-raw-jni-callback}/src/main/res/xml/data_extraction_rules.xml (100%) rename {hello-swift-callback => hello-swift-raw-jni-callback}/src/main/swift/.gitignore (100%) rename {hello-swift-callback => hello-swift-raw-jni-callback}/src/main/swift/Package.swift (51%) rename {hello-swift-callback => hello-swift-raw-jni-callback}/src/main/swift/Sources/hello-swift-callback/hello-swift-callback.swift (97%) rename {hello-swift => hello-swift-raw-jni-library}/.gitignore (100%) rename {hello-swift-library => hello-swift-raw-jni-library}/README.md (68%) rename {hello-swift-library => hello-swift-raw-jni-library}/build.gradle.kts (100%) rename {hello-swift-library => hello-swift-raw-jni-library}/src/androidTest/java/org/example/swiftlibrary/SwiftLibraryTest.kt (100%) rename {hello-swift-library => hello-swift-raw-jni-library}/src/main/AndroidManifest.xml (100%) rename {hello-swift-library => hello-swift-raw-jni-library}/src/main/java/org/example/swiftlibrary/SwiftLibrary.kt (91%) rename {hello-swift-library => hello-swift-raw-jni-library}/src/main/swift/.gitignore (100%) rename {hello-swift-library => hello-swift-raw-jni-library}/src/main/swift/Package.swift (51%) rename {hello-swift-library => hello-swift-raw-jni-library}/src/main/swift/Sources/helloswift/helloswift.swift (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/.gitignore (100%) rename {hello-swift => hello-swift-raw-jni}/README.md (75%) rename {hello-swift => hello-swift-raw-jni}/build.gradle.kts (100%) rename {hello-swift => hello-swift-raw-jni}/screenshot.png (100%) rename {hello-swift => hello-swift-raw-jni}/src/main/AndroidManifest.xml (100%) rename {hello-swift => hello-swift-raw-jni}/src/main/java/org/example/helloswift/MainActivity.kt (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/drawable/ic_launcher_background.xml (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/drawable/ic_launcher_foreground.xml (100%) rename {hello-swift => hello-swift-raw-jni}/src/main/res/layout/activity_main.xml (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/mipmap-anydpi/ic_launcher.xml (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/mipmap-anydpi/ic_launcher_round.xml (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/mipmap-hdpi/ic_launcher.webp (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/mipmap-hdpi/ic_launcher_round.webp (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/mipmap-mdpi/ic_launcher.webp (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/mipmap-mdpi/ic_launcher_round.webp (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/mipmap-xhdpi/ic_launcher.webp (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/mipmap-xhdpi/ic_launcher_round.webp (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/mipmap-xxhdpi/ic_launcher.webp (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/mipmap-xxxhdpi/ic_launcher.webp (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp (100%) rename {hello-swift => hello-swift-raw-jni}/src/main/res/values-night/themes.xml (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/values/colors.xml (100%) rename {hello-swift => hello-swift-raw-jni}/src/main/res/values/strings.xml (100%) rename {hello-swift => hello-swift-raw-jni}/src/main/res/values/themes.xml (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/xml/backup_rules.xml (100%) rename {swift-java-hashing-example/hashing-app => hello-swift-raw-jni}/src/main/res/xml/data_extraction_rules.xml (100%) rename {hello-swift => hello-swift-raw-jni}/src/main/swift/.gitignore (100%) rename {hello-swift => hello-swift-raw-jni}/src/main/swift/Package.swift (100%) rename {hello-swift => hello-swift-raw-jni}/src/main/swift/Sources/helloswift/helloswift.swift (100%) diff --git a/README.md b/README.md index be5aefc..02053fc 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,11 @@ This repository contains example applications that demonstrate how to use the [S ## Available Examples -- **[hello-swift](hello-swift/)** - basic Swift integration that calls a Swift function. -- **[hello-swift-callback](hello-swift-callback/)** - demonstrates bidirectional communication with Swift timer callbacks updating Android UI. -- **[hello-swift-library](hello-swift-library/)** - shows how to package Swift code as a reusable Android library component. +Examples using [swift-java](https://github.com/swiftlang/swift-java) to generate necessary Swift/Java bridging: +- **[hello-swift-java](hello-swift-java/)** - application that demonstrates how to call Swift code from an Android app with automatically generated Java wrappers and JNI code using [swift-java](https://github.com/swiftlang/swift-java). + +Examples using raw JNI, without generated bridging sources: +- **[hello-swift-raw-jni](hello-swift-raw-jni/)** - basic Swift integration that calls a Swift function. +- **[hello-swift-raw-jni-callback](hello-swift-raw-jni-callback/)** - demonstrates bidirectional communication with Swift timer callbacks updating Android UI. +- **[hello-swift-raw-jni-library](hello-swift-raw-jni-library/)** - shows how to package Swift code as a reusable Android library component. - **[native-activity](native-activity/)** - complete native Android activity with OpenGL ES rendering written entirely in Swift. -- **[swift-java-hashing-example](swift-java-hashing-example/)** - application that demonstrates how to call Swift code from an Android app with automatically generated Java wrappers and JNI code using [swift-java](https://github.com/swiftlang/swift-java). diff --git a/swift-java-hashing-example/.gitignore b/hello-swift-java/.gitignore similarity index 100% rename from swift-java-hashing-example/.gitignore rename to hello-swift-java/.gitignore diff --git a/swift-java-hashing-example/README.md b/hello-swift-java/README.md similarity index 92% rename from swift-java-hashing-example/README.md rename to hello-swift-java/README.md index 4d1921a..edd512a 100644 --- a/swift-java-hashing-example/README.md +++ b/hello-swift-java/README.md @@ -1,9 +1,8 @@ # swift-java on Android This example contains a sample Android application that demonstrates how to call Swift code from a Android app. -The example consists of an Android application (`hashing-app`) and a Swift library (`hashing-lib`) that performs a SHA256 hash on a given string. -The Swift library uses [swift-java](https://github.com/swiftlang/swift-java) and the new JNI mode to automatically -generate Java wrappers for calling into the Swift library. + +The example consists of an Android application (`hashing-app`) and a Swift library (`hashing-lib`) that performs a SHA256 hash on a given string. The Swift library uses [swift-java](https://github.com/swiftlang/swift-java) and the new JNI mode to **automatically generate Java wrappers** for calling into the Swift library. ![IDE Screenshot](resources/ide.png) @@ -27,7 +26,7 @@ Before you can build and run this project, you need to have the following instal ### Prepare Swift Android SDK and matching Swift -Currently these examples utilize very recent nightly Swift Android SDK versions. In order to install these, you can use Swiftly (the Swift toolchain installer): +Currently, these examples utilize very recent nightly Swift Android SDK versions. In order to install these, you can use Swiftly (the Swift toolchain installer): You can follow [these instructions](https://www.swift.org/documentation/articles/swift-sdk-for-android-getting-started.html) to install an appropriate Swift SDK for Android. diff --git a/hello-swift-callback/.gitignore b/hello-swift-java/hashing-app/.gitignore similarity index 100% rename from hello-swift-callback/.gitignore rename to hello-swift-java/hashing-app/.gitignore diff --git a/swift-java-hashing-example/hashing-app/build.gradle.kts b/hello-swift-java/hashing-app/build.gradle.kts similarity index 96% rename from swift-java-hashing-example/hashing-app/build.gradle.kts rename to hello-swift-java/hashing-app/build.gradle.kts index 31a9ad3..bddfdc0 100644 --- a/swift-java-hashing-example/hashing-app/build.gradle.kts +++ b/hello-swift-java/hashing-app/build.gradle.kts @@ -40,7 +40,6 @@ android { } dependencies { - implementation(libs.androidx.core.ktx) implementation(libs.androidx.lifecycle.runtime.ktx) implementation(libs.androidx.activity.compose) @@ -49,7 +48,7 @@ dependencies { implementation(libs.androidx.ui.graphics) implementation(libs.androidx.ui.tooling.preview) implementation(libs.androidx.material3) - implementation(project(":hashing-lib")) + implementation(project(":hello-swift-java-hashing-lib")) testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.espresso.core) diff --git a/swift-java-hashing-example/hashing-app/proguard-rules.pro b/hello-swift-java/hashing-app/proguard-rules.pro similarity index 100% rename from swift-java-hashing-example/hashing-app/proguard-rules.pro rename to hello-swift-java/hashing-app/proguard-rules.pro diff --git a/swift-java-hashing-example/hashing-app/src/androidTest/java/com/example/hashingapp/ExampleInstrumentedTest.kt b/hello-swift-java/hashing-app/src/androidTest/java/com/example/hashingapp/ExampleInstrumentedTest.kt similarity index 100% rename from swift-java-hashing-example/hashing-app/src/androidTest/java/com/example/hashingapp/ExampleInstrumentedTest.kt rename to hello-swift-java/hashing-app/src/androidTest/java/com/example/hashingapp/ExampleInstrumentedTest.kt diff --git a/swift-java-hashing-example/hashing-app/src/main/AndroidManifest.xml b/hello-swift-java/hashing-app/src/main/AndroidManifest.xml similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/AndroidManifest.xml rename to hello-swift-java/hashing-app/src/main/AndroidManifest.xml diff --git a/swift-java-hashing-example/hashing-app/src/main/java/com/example/hashingapp/MainActivity.kt b/hello-swift-java/hashing-app/src/main/java/com/example/hashingapp/MainActivity.kt similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/java/com/example/hashingapp/MainActivity.kt rename to hello-swift-java/hashing-app/src/main/java/com/example/hashingapp/MainActivity.kt diff --git a/swift-java-hashing-example/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Color.kt b/hello-swift-java/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Color.kt similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Color.kt rename to hello-swift-java/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Color.kt diff --git a/swift-java-hashing-example/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Theme.kt b/hello-swift-java/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Theme.kt similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Theme.kt rename to hello-swift-java/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Theme.kt diff --git a/swift-java-hashing-example/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Type.kt b/hello-swift-java/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Type.kt similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Type.kt rename to hello-swift-java/hashing-app/src/main/java/com/example/hashingapp/ui/theme/Type.kt diff --git a/hello-swift-callback/src/main/res/drawable/ic_launcher_background.xml b/hello-swift-java/hashing-app/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from hello-swift-callback/src/main/res/drawable/ic_launcher_background.xml rename to hello-swift-java/hashing-app/src/main/res/drawable/ic_launcher_background.xml diff --git a/hello-swift-callback/src/main/res/drawable/ic_launcher_foreground.xml b/hello-swift-java/hashing-app/src/main/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from hello-swift-callback/src/main/res/drawable/ic_launcher_foreground.xml rename to hello-swift-java/hashing-app/src/main/res/drawable/ic_launcher_foreground.xml diff --git a/hello-swift-callback/src/main/res/mipmap-anydpi/ic_launcher.xml b/hello-swift-java/hashing-app/src/main/res/mipmap-anydpi/ic_launcher.xml similarity index 100% rename from hello-swift-callback/src/main/res/mipmap-anydpi/ic_launcher.xml rename to hello-swift-java/hashing-app/src/main/res/mipmap-anydpi/ic_launcher.xml diff --git a/hello-swift-callback/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/hello-swift-java/hashing-app/src/main/res/mipmap-anydpi/ic_launcher_round.xml similarity index 100% rename from hello-swift-callback/src/main/res/mipmap-anydpi/ic_launcher_round.xml rename to hello-swift-java/hashing-app/src/main/res/mipmap-anydpi/ic_launcher_round.xml diff --git a/hello-swift-callback/src/main/res/mipmap-hdpi/ic_launcher.webp b/hello-swift-java/hashing-app/src/main/res/mipmap-hdpi/ic_launcher.webp similarity index 100% rename from hello-swift-callback/src/main/res/mipmap-hdpi/ic_launcher.webp rename to hello-swift-java/hashing-app/src/main/res/mipmap-hdpi/ic_launcher.webp diff --git a/hello-swift-callback/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/hello-swift-java/hashing-app/src/main/res/mipmap-hdpi/ic_launcher_round.webp similarity index 100% rename from hello-swift-callback/src/main/res/mipmap-hdpi/ic_launcher_round.webp rename to hello-swift-java/hashing-app/src/main/res/mipmap-hdpi/ic_launcher_round.webp diff --git a/hello-swift-callback/src/main/res/mipmap-mdpi/ic_launcher.webp b/hello-swift-java/hashing-app/src/main/res/mipmap-mdpi/ic_launcher.webp similarity index 100% rename from hello-swift-callback/src/main/res/mipmap-mdpi/ic_launcher.webp rename to hello-swift-java/hashing-app/src/main/res/mipmap-mdpi/ic_launcher.webp diff --git a/hello-swift-callback/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/hello-swift-java/hashing-app/src/main/res/mipmap-mdpi/ic_launcher_round.webp similarity index 100% rename from hello-swift-callback/src/main/res/mipmap-mdpi/ic_launcher_round.webp rename to hello-swift-java/hashing-app/src/main/res/mipmap-mdpi/ic_launcher_round.webp diff --git a/hello-swift-callback/src/main/res/mipmap-xhdpi/ic_launcher.webp b/hello-swift-java/hashing-app/src/main/res/mipmap-xhdpi/ic_launcher.webp similarity index 100% rename from hello-swift-callback/src/main/res/mipmap-xhdpi/ic_launcher.webp rename to hello-swift-java/hashing-app/src/main/res/mipmap-xhdpi/ic_launcher.webp diff --git a/hello-swift-callback/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/hello-swift-java/hashing-app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp similarity index 100% rename from hello-swift-callback/src/main/res/mipmap-xhdpi/ic_launcher_round.webp rename to hello-swift-java/hashing-app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp diff --git a/hello-swift-callback/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/hello-swift-java/hashing-app/src/main/res/mipmap-xxhdpi/ic_launcher.webp similarity index 100% rename from hello-swift-callback/src/main/res/mipmap-xxhdpi/ic_launcher.webp rename to hello-swift-java/hashing-app/src/main/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/hello-swift-callback/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/hello-swift-java/hashing-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp similarity index 100% rename from hello-swift-callback/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp rename to hello-swift-java/hashing-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp diff --git a/hello-swift-callback/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/hello-swift-java/hashing-app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp similarity index 100% rename from hello-swift-callback/src/main/res/mipmap-xxxhdpi/ic_launcher.webp rename to hello-swift-java/hashing-app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/hello-swift-callback/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/hello-swift-java/hashing-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp similarity index 100% rename from hello-swift-callback/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp rename to hello-swift-java/hashing-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp diff --git a/hello-swift-callback/src/main/res/values/colors.xml b/hello-swift-java/hashing-app/src/main/res/values/colors.xml similarity index 100% rename from hello-swift-callback/src/main/res/values/colors.xml rename to hello-swift-java/hashing-app/src/main/res/values/colors.xml diff --git a/swift-java-hashing-example/hashing-app/src/main/res/values/strings.xml b/hello-swift-java/hashing-app/src/main/res/values/strings.xml similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/values/strings.xml rename to hello-swift-java/hashing-app/src/main/res/values/strings.xml diff --git a/swift-java-hashing-example/hashing-app/src/main/res/values/themes.xml b/hello-swift-java/hashing-app/src/main/res/values/themes.xml similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/values/themes.xml rename to hello-swift-java/hashing-app/src/main/res/values/themes.xml diff --git a/hello-swift-callback/src/main/res/xml/backup_rules.xml b/hello-swift-java/hashing-app/src/main/res/xml/backup_rules.xml similarity index 100% rename from hello-swift-callback/src/main/res/xml/backup_rules.xml rename to hello-swift-java/hashing-app/src/main/res/xml/backup_rules.xml diff --git a/hello-swift-callback/src/main/res/xml/data_extraction_rules.xml b/hello-swift-java/hashing-app/src/main/res/xml/data_extraction_rules.xml similarity index 100% rename from hello-swift-callback/src/main/res/xml/data_extraction_rules.xml rename to hello-swift-java/hashing-app/src/main/res/xml/data_extraction_rules.xml diff --git a/swift-java-hashing-example/hashing-app/src/test/java/com/example/hashingapp/ExampleUnitTest.kt b/hello-swift-java/hashing-app/src/test/java/com/example/hashingapp/ExampleUnitTest.kt similarity index 100% rename from swift-java-hashing-example/hashing-app/src/test/java/com/example/hashingapp/ExampleUnitTest.kt rename to hello-swift-java/hashing-app/src/test/java/com/example/hashingapp/ExampleUnitTest.kt diff --git a/swift-java-hashing-example/hashing-lib/Package.swift b/hello-swift-java/hashing-lib/Package.swift similarity index 100% rename from swift-java-hashing-example/hashing-lib/Package.swift rename to hello-swift-java/hashing-lib/Package.swift diff --git a/swift-java-hashing-example/hashing-lib/Sources/SwiftHashing/SwiftHashing.swift b/hello-swift-java/hashing-lib/Sources/SwiftHashing/SwiftHashing.swift similarity index 100% rename from swift-java-hashing-example/hashing-lib/Sources/SwiftHashing/SwiftHashing.swift rename to hello-swift-java/hashing-lib/Sources/SwiftHashing/SwiftHashing.swift diff --git a/swift-java-hashing-example/hashing-lib/Sources/SwiftHashing/swift-java.config b/hello-swift-java/hashing-lib/Sources/SwiftHashing/swift-java.config similarity index 100% rename from swift-java-hashing-example/hashing-lib/Sources/SwiftHashing/swift-java.config rename to hello-swift-java/hashing-lib/Sources/SwiftHashing/swift-java.config diff --git a/swift-java-hashing-example/hashing-lib/Tests/SwiftHashingTests/SwiftHashingTests.swift b/hello-swift-java/hashing-lib/Tests/SwiftHashingTests/SwiftHashingTests.swift similarity index 100% rename from swift-java-hashing-example/hashing-lib/Tests/SwiftHashingTests/SwiftHashingTests.swift rename to hello-swift-java/hashing-lib/Tests/SwiftHashingTests/SwiftHashingTests.swift diff --git a/swift-java-hashing-example/hashing-lib/build.gradle b/hello-swift-java/hashing-lib/build.gradle similarity index 100% rename from swift-java-hashing-example/hashing-lib/build.gradle rename to hello-swift-java/hashing-lib/build.gradle diff --git a/swift-java-hashing-example/hashing-lib/gradle.properties b/hello-swift-java/hashing-lib/gradle.properties similarity index 100% rename from swift-java-hashing-example/hashing-lib/gradle.properties rename to hello-swift-java/hashing-lib/gradle.properties diff --git a/swift-java-hashing-example/resources/ide.png b/hello-swift-java/resources/ide.png similarity index 100% rename from swift-java-hashing-example/resources/ide.png rename to hello-swift-java/resources/ide.png diff --git a/hello-swift-library/.gitignore b/hello-swift-raw-jni-callback/.gitignore similarity index 100% rename from hello-swift-library/.gitignore rename to hello-swift-raw-jni-callback/.gitignore diff --git a/hello-swift-callback/README.md b/hello-swift-raw-jni-callback/README.md similarity index 72% rename from hello-swift-callback/README.md rename to hello-swift-raw-jni-callback/README.md index 723d619..065c995 100644 --- a/hello-swift-callback/README.md +++ b/hello-swift-raw-jni-callback/README.md @@ -1,6 +1,6 @@ -# Swift to Android Callbacks +# Swift to Android Callbacks using Raw JNI -This example demonstrates bidirectional communication between Swift and Android. The Swift code runs a timer that calls back to Android every second to update the UI with the current time (HH:MM:SS format). +This example demonstrates bidirectional communication between Swift and Android, without the use of swift-java interoperability support, just by using raw JNI. The Swift code runs a timer that calls back to Android every second to update the UI with the current time (HH:MM:SS format). ![Screenshot](screenshot.png) @@ -23,7 +23,7 @@ Before you can build and run this project, you need to have the following instal 1. Open the `swift-android-examples` project in Android Studio. -2. Select the `hello-swift-callback` Gradle target. +2. Select the `hello-swift-raw-jni-callback` Gradle target. 3. Run the app on an Android emulator or a physical device. @@ -31,8 +31,8 @@ Before you can build and run this project, you need to have the following instal ```bash # Build the example -./gradlew :hello-swift-callback:assembleDebug +./gradlew :hello-swift-raw-jni-callback:assembleDebug # Install on device/emulator -./gradlew :hello-swift-callback:installDebug +./gradlew :hello-swift-raw-jni-callback:installDebug ``` diff --git a/hello-swift-callback/build.gradle.kts b/hello-swift-raw-jni-callback/build.gradle.kts similarity index 100% rename from hello-swift-callback/build.gradle.kts rename to hello-swift-raw-jni-callback/build.gradle.kts diff --git a/hello-swift-callback/screenshot.png b/hello-swift-raw-jni-callback/screenshot.png similarity index 100% rename from hello-swift-callback/screenshot.png rename to hello-swift-raw-jni-callback/screenshot.png diff --git a/hello-swift-callback/src/main/AndroidManifest.xml b/hello-swift-raw-jni-callback/src/main/AndroidManifest.xml similarity index 100% rename from hello-swift-callback/src/main/AndroidManifest.xml rename to hello-swift-raw-jni-callback/src/main/AndroidManifest.xml diff --git a/hello-swift-callback/src/main/java/org/example/helloswift/MainActivity.kt b/hello-swift-raw-jni-callback/src/main/java/org/example/helloswift/MainActivity.kt similarity index 92% rename from hello-swift-callback/src/main/java/org/example/helloswift/MainActivity.kt rename to hello-swift-raw-jni-callback/src/main/java/org/example/helloswift/MainActivity.kt index e60f4a4..69a49a1 100644 --- a/hello-swift-callback/src/main/java/org/example/helloswift/MainActivity.kt +++ b/hello-swift-raw-jni-callback/src/main/java/org/example/helloswift/MainActivity.kt @@ -72,9 +72,9 @@ class MainActivity : AppCompatActivity() { external fun stopTicks() companion object { - // Used to load the 'hello-swift-callback' library on application startup. + // Used to load the 'hello-swift-raw-jni-callback' library on application startup. init { - System.loadLibrary("hello-swift-callback") + System.loadLibrary("hello-swift-raw-jni-callback") } } } diff --git a/hello-swift/src/main/res/drawable/ic_launcher_background.xml b/hello-swift-raw-jni-callback/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from hello-swift/src/main/res/drawable/ic_launcher_background.xml rename to hello-swift-raw-jni-callback/src/main/res/drawable/ic_launcher_background.xml diff --git a/hello-swift/src/main/res/drawable/ic_launcher_foreground.xml b/hello-swift-raw-jni-callback/src/main/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from hello-swift/src/main/res/drawable/ic_launcher_foreground.xml rename to hello-swift-raw-jni-callback/src/main/res/drawable/ic_launcher_foreground.xml diff --git a/hello-swift-callback/src/main/res/layout/activity_main.xml b/hello-swift-raw-jni-callback/src/main/res/layout/activity_main.xml similarity index 100% rename from hello-swift-callback/src/main/res/layout/activity_main.xml rename to hello-swift-raw-jni-callback/src/main/res/layout/activity_main.xml diff --git a/hello-swift/src/main/res/mipmap-anydpi/ic_launcher.xml b/hello-swift-raw-jni-callback/src/main/res/mipmap-anydpi/ic_launcher.xml similarity index 100% rename from hello-swift/src/main/res/mipmap-anydpi/ic_launcher.xml rename to hello-swift-raw-jni-callback/src/main/res/mipmap-anydpi/ic_launcher.xml diff --git a/hello-swift/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/hello-swift-raw-jni-callback/src/main/res/mipmap-anydpi/ic_launcher_round.xml similarity index 100% rename from hello-swift/src/main/res/mipmap-anydpi/ic_launcher_round.xml rename to hello-swift-raw-jni-callback/src/main/res/mipmap-anydpi/ic_launcher_round.xml diff --git a/hello-swift/src/main/res/mipmap-hdpi/ic_launcher.webp b/hello-swift-raw-jni-callback/src/main/res/mipmap-hdpi/ic_launcher.webp similarity index 100% rename from hello-swift/src/main/res/mipmap-hdpi/ic_launcher.webp rename to hello-swift-raw-jni-callback/src/main/res/mipmap-hdpi/ic_launcher.webp diff --git a/hello-swift/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/hello-swift-raw-jni-callback/src/main/res/mipmap-hdpi/ic_launcher_round.webp similarity index 100% rename from hello-swift/src/main/res/mipmap-hdpi/ic_launcher_round.webp rename to hello-swift-raw-jni-callback/src/main/res/mipmap-hdpi/ic_launcher_round.webp diff --git a/hello-swift/src/main/res/mipmap-mdpi/ic_launcher.webp b/hello-swift-raw-jni-callback/src/main/res/mipmap-mdpi/ic_launcher.webp similarity index 100% rename from hello-swift/src/main/res/mipmap-mdpi/ic_launcher.webp rename to hello-swift-raw-jni-callback/src/main/res/mipmap-mdpi/ic_launcher.webp diff --git a/hello-swift/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/hello-swift-raw-jni-callback/src/main/res/mipmap-mdpi/ic_launcher_round.webp similarity index 100% rename from hello-swift/src/main/res/mipmap-mdpi/ic_launcher_round.webp rename to hello-swift-raw-jni-callback/src/main/res/mipmap-mdpi/ic_launcher_round.webp diff --git a/hello-swift/src/main/res/mipmap-xhdpi/ic_launcher.webp b/hello-swift-raw-jni-callback/src/main/res/mipmap-xhdpi/ic_launcher.webp similarity index 100% rename from hello-swift/src/main/res/mipmap-xhdpi/ic_launcher.webp rename to hello-swift-raw-jni-callback/src/main/res/mipmap-xhdpi/ic_launcher.webp diff --git a/hello-swift/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/hello-swift-raw-jni-callback/src/main/res/mipmap-xhdpi/ic_launcher_round.webp similarity index 100% rename from hello-swift/src/main/res/mipmap-xhdpi/ic_launcher_round.webp rename to hello-swift-raw-jni-callback/src/main/res/mipmap-xhdpi/ic_launcher_round.webp diff --git a/hello-swift/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/hello-swift-raw-jni-callback/src/main/res/mipmap-xxhdpi/ic_launcher.webp similarity index 100% rename from hello-swift/src/main/res/mipmap-xxhdpi/ic_launcher.webp rename to hello-swift-raw-jni-callback/src/main/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/hello-swift/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/hello-swift-raw-jni-callback/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp similarity index 100% rename from hello-swift/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp rename to hello-swift-raw-jni-callback/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp diff --git a/hello-swift/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/hello-swift-raw-jni-callback/src/main/res/mipmap-xxxhdpi/ic_launcher.webp similarity index 100% rename from hello-swift/src/main/res/mipmap-xxxhdpi/ic_launcher.webp rename to hello-swift-raw-jni-callback/src/main/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/hello-swift/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/hello-swift-raw-jni-callback/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp similarity index 100% rename from hello-swift/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp rename to hello-swift-raw-jni-callback/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp diff --git a/hello-swift-callback/src/main/res/values-night/themes.xml b/hello-swift-raw-jni-callback/src/main/res/values-night/themes.xml similarity index 100% rename from hello-swift-callback/src/main/res/values-night/themes.xml rename to hello-swift-raw-jni-callback/src/main/res/values-night/themes.xml diff --git a/hello-swift/src/main/res/values/colors.xml b/hello-swift-raw-jni-callback/src/main/res/values/colors.xml similarity index 100% rename from hello-swift/src/main/res/values/colors.xml rename to hello-swift-raw-jni-callback/src/main/res/values/colors.xml diff --git a/hello-swift-callback/src/main/res/values/strings.xml b/hello-swift-raw-jni-callback/src/main/res/values/strings.xml similarity index 100% rename from hello-swift-callback/src/main/res/values/strings.xml rename to hello-swift-raw-jni-callback/src/main/res/values/strings.xml diff --git a/hello-swift-callback/src/main/res/values/themes.xml b/hello-swift-raw-jni-callback/src/main/res/values/themes.xml similarity index 100% rename from hello-swift-callback/src/main/res/values/themes.xml rename to hello-swift-raw-jni-callback/src/main/res/values/themes.xml diff --git a/hello-swift/src/main/res/xml/backup_rules.xml b/hello-swift-raw-jni-callback/src/main/res/xml/backup_rules.xml similarity index 100% rename from hello-swift/src/main/res/xml/backup_rules.xml rename to hello-swift-raw-jni-callback/src/main/res/xml/backup_rules.xml diff --git a/hello-swift/src/main/res/xml/data_extraction_rules.xml b/hello-swift-raw-jni-callback/src/main/res/xml/data_extraction_rules.xml similarity index 100% rename from hello-swift/src/main/res/xml/data_extraction_rules.xml rename to hello-swift-raw-jni-callback/src/main/res/xml/data_extraction_rules.xml diff --git a/hello-swift-callback/src/main/swift/.gitignore b/hello-swift-raw-jni-callback/src/main/swift/.gitignore similarity index 100% rename from hello-swift-callback/src/main/swift/.gitignore rename to hello-swift-raw-jni-callback/src/main/swift/.gitignore diff --git a/hello-swift-callback/src/main/swift/Package.swift b/hello-swift-raw-jni-callback/src/main/swift/Package.swift similarity index 51% rename from hello-swift-callback/src/main/swift/Package.swift rename to hello-swift-raw-jni-callback/src/main/swift/Package.swift index 792ce4e..84c2b44 100644 --- a/hello-swift-callback/src/main/swift/Package.swift +++ b/hello-swift-raw-jni-callback/src/main/swift/Package.swift @@ -4,11 +4,11 @@ import PackageDescription let package = Package( - name: "hello-swift-callback", + name: "hello-swift-raw-jni-callback", products: [ - .library(name: "hello-swift-callback", type: .dynamic, targets: ["hello-swift-callback"]), + .library(name: "hello-swift-raw-jni-callback", type: .dynamic, targets: ["hello-swift-raw-jni-callback"]), ], targets: [ - .target(name: "hello-swift-callback") + .target(name: "hello-swift-raw-jni-callback") ] ) diff --git a/hello-swift-callback/src/main/swift/Sources/hello-swift-callback/hello-swift-callback.swift b/hello-swift-raw-jni-callback/src/main/swift/Sources/hello-swift-callback/hello-swift-callback.swift similarity index 97% rename from hello-swift-callback/src/main/swift/Sources/hello-swift-callback/hello-swift-callback.swift rename to hello-swift-raw-jni-callback/src/main/swift/Sources/hello-swift-callback/hello-swift-callback.swift index cd20234..2e76e4f 100644 --- a/hello-swift-callback/src/main/swift/Sources/hello-swift-callback/hello-swift-callback.swift +++ b/hello-swift-raw-jni-callback/src/main/swift/Sources/hello-swift-callback/hello-swift-callback.swift @@ -30,7 +30,7 @@ struct JMethodID: @unchecked Sendable { let id: jmethodID } -let queue = DispatchQueue(label: "hello-swift-callback") +let queue = DispatchQueue(label: "hello-swift-raw-jni-callback") var workItem: DispatchWorkItem? = nil var activityRef: jobject? = nil diff --git a/hello-swift/.gitignore b/hello-swift-raw-jni-library/.gitignore similarity index 100% rename from hello-swift/.gitignore rename to hello-swift-raw-jni-library/.gitignore diff --git a/hello-swift-library/README.md b/hello-swift-raw-jni-library/README.md similarity index 68% rename from hello-swift-library/README.md rename to hello-swift-raw-jni-library/README.md index 3047ba0..564d8b6 100644 --- a/hello-swift-library/README.md +++ b/hello-swift-raw-jni-library/README.md @@ -1,6 +1,6 @@ # Swift as Android Library -This example demonstrates how to package Swift code as a reusable Android library. It shows how to create a Swift library that can be consumed by other Android applications, making Swift functionality available as a standard Android library component. +This example demonstrates how to package Swift code as a reusable Android library, without the use of swift-java interoperability support, just by using raw JNI. It shows how to create a Swift library that can be consumed by other Android applications, making Swift functionality available as a standard Android library component. ## Overview @@ -21,7 +21,7 @@ Before you can build and run this project, you need to have the following instal 1. Open the `swift-android-examples` project in Android Studio. -2. Select the `hello-swift-library` Gradle target. +2. Select the `hello-swift-raw-jni-library` Gradle target. 3. Build the library (it doesn't have a runnable app). @@ -29,19 +29,19 @@ Before you can build and run this project, you need to have the following instal ```bash # Build the library -./gradlew :hello-swift-library:assembleDebug +./gradlew :hello-swift-raw-jni-library:assembleDebug # Build the AAR file -./gradlew :hello-swift-library:bundleReleaseAar +./gradlew :hello-swift-raw-jni-library:bundleReleaseAar ``` -After a successful build, the Android library will be located at `hello-swift-library/build/outputs/aar/hello-swift-library-release.aar`. +After a successful build, the Android library will be located at `hello-swift-raw-jni-library/build/outputs/aar/hello-swift-raw-jni-library-release.aar`. ## Using the library in other projects 1. Copy the generated AAR file to your project's `libs/` directory 2. Add the dependency in your `build.gradle`: ```gradle - implementation files('libs/hello-swift-library-release.aar') + implementation files('libs/hello-swift-raw-jni-library-release.aar') ``` 3. Use the `SwiftLibrary` class in your code diff --git a/hello-swift-library/build.gradle.kts b/hello-swift-raw-jni-library/build.gradle.kts similarity index 100% rename from hello-swift-library/build.gradle.kts rename to hello-swift-raw-jni-library/build.gradle.kts diff --git a/hello-swift-library/src/androidTest/java/org/example/swiftlibrary/SwiftLibraryTest.kt b/hello-swift-raw-jni-library/src/androidTest/java/org/example/swiftlibrary/SwiftLibraryTest.kt similarity index 100% rename from hello-swift-library/src/androidTest/java/org/example/swiftlibrary/SwiftLibraryTest.kt rename to hello-swift-raw-jni-library/src/androidTest/java/org/example/swiftlibrary/SwiftLibraryTest.kt diff --git a/hello-swift-library/src/main/AndroidManifest.xml b/hello-swift-raw-jni-library/src/main/AndroidManifest.xml similarity index 100% rename from hello-swift-library/src/main/AndroidManifest.xml rename to hello-swift-raw-jni-library/src/main/AndroidManifest.xml diff --git a/hello-swift-library/src/main/java/org/example/swiftlibrary/SwiftLibrary.kt b/hello-swift-raw-jni-library/src/main/java/org/example/swiftlibrary/SwiftLibrary.kt similarity index 91% rename from hello-swift-library/src/main/java/org/example/swiftlibrary/SwiftLibrary.kt rename to hello-swift-raw-jni-library/src/main/java/org/example/swiftlibrary/SwiftLibrary.kt index c72a86c..4298b84 100644 --- a/hello-swift-library/src/main/java/org/example/swiftlibrary/SwiftLibrary.kt +++ b/hello-swift-raw-jni-library/src/main/java/org/example/swiftlibrary/SwiftLibrary.kt @@ -18,7 +18,7 @@ class SwiftLibrary { companion object { init { - System.loadLibrary("hello-swift-library") + System.loadLibrary("hello-swift-raw-jni-library") } } } diff --git a/hello-swift-library/src/main/swift/.gitignore b/hello-swift-raw-jni-library/src/main/swift/.gitignore similarity index 100% rename from hello-swift-library/src/main/swift/.gitignore rename to hello-swift-raw-jni-library/src/main/swift/.gitignore diff --git a/hello-swift-library/src/main/swift/Package.swift b/hello-swift-raw-jni-library/src/main/swift/Package.swift similarity index 51% rename from hello-swift-library/src/main/swift/Package.swift rename to hello-swift-raw-jni-library/src/main/swift/Package.swift index 52a4456..ad9d3b4 100644 --- a/hello-swift-library/src/main/swift/Package.swift +++ b/hello-swift-raw-jni-library/src/main/swift/Package.swift @@ -4,11 +4,11 @@ import PackageDescription let package = Package( - name: "hello-swift-library", + name: "hello-swift-raw-jni-library", products: [ - .library(name: "hello-swift-library", type: .dynamic, targets: ["hello-swift-library"]), + .library(name: "hello-swift-raw-jni-library", type: .dynamic, targets: ["hello-swift-raw-jni-library"]), ], targets: [ - .target(name: "hello-swift-library") + .target(name: "hello-swift-raw-jni-library") ] ) diff --git a/hello-swift-library/src/main/swift/Sources/helloswift/helloswift.swift b/hello-swift-raw-jni-library/src/main/swift/Sources/helloswift/helloswift.swift similarity index 100% rename from hello-swift-library/src/main/swift/Sources/helloswift/helloswift.swift rename to hello-swift-raw-jni-library/src/main/swift/Sources/helloswift/helloswift.swift diff --git a/swift-java-hashing-example/hashing-app/.gitignore b/hello-swift-raw-jni/.gitignore similarity index 100% rename from swift-java-hashing-example/hashing-app/.gitignore rename to hello-swift-raw-jni/.gitignore diff --git a/hello-swift/README.md b/hello-swift-raw-jni/README.md similarity index 75% rename from hello-swift/README.md rename to hello-swift-raw-jni/README.md index 7104af5..f1a1fe1 100644 --- a/hello-swift/README.md +++ b/hello-swift-raw-jni/README.md @@ -1,6 +1,6 @@ # Basic Swift Integration -This example demonstrates the most basic Swift integration pattern with Android. The app calls a Swift function that returns a "Hello from Swift ❤️" message and displays it in the Android UI. +This example demonstrates the most basic Swift integration pattern with Android, without the use of swift-java interoperability support, just by using raw JNI. The app calls a Swift function that returns a "Hello from Swift ❤️" message and displays it in the Android UI. ![Screenshot](screenshot.png) @@ -23,7 +23,7 @@ Before you can build and run this project, you need to have the following instal 1. Open the `swift-android-examples` project in Android Studio. -2. Select the `hello-swift` Gradle target. +2. Select the `hello-swift-raw-jni` Gradle target. 3. Run the app on an Android emulator or a physical device. @@ -31,8 +31,8 @@ Before you can build and run this project, you need to have the following instal ```bash # Build the example -./gradlew :hello-swift:assembleDebug +./gradlew :hello-swift-raw-jni:assembleDebug # Install on device/emulator -./gradlew :hello-swift:installDebug +./gradlew :hello-swift-raw-jni:installDebug ``` diff --git a/hello-swift/build.gradle.kts b/hello-swift-raw-jni/build.gradle.kts similarity index 100% rename from hello-swift/build.gradle.kts rename to hello-swift-raw-jni/build.gradle.kts diff --git a/hello-swift/screenshot.png b/hello-swift-raw-jni/screenshot.png similarity index 100% rename from hello-swift/screenshot.png rename to hello-swift-raw-jni/screenshot.png diff --git a/hello-swift/src/main/AndroidManifest.xml b/hello-swift-raw-jni/src/main/AndroidManifest.xml similarity index 100% rename from hello-swift/src/main/AndroidManifest.xml rename to hello-swift-raw-jni/src/main/AndroidManifest.xml diff --git a/hello-swift/src/main/java/org/example/helloswift/MainActivity.kt b/hello-swift-raw-jni/src/main/java/org/example/helloswift/MainActivity.kt similarity index 100% rename from hello-swift/src/main/java/org/example/helloswift/MainActivity.kt rename to hello-swift-raw-jni/src/main/java/org/example/helloswift/MainActivity.kt diff --git a/swift-java-hashing-example/hashing-app/src/main/res/drawable/ic_launcher_background.xml b/hello-swift-raw-jni/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/drawable/ic_launcher_background.xml rename to hello-swift-raw-jni/src/main/res/drawable/ic_launcher_background.xml diff --git a/swift-java-hashing-example/hashing-app/src/main/res/drawable/ic_launcher_foreground.xml b/hello-swift-raw-jni/src/main/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/drawable/ic_launcher_foreground.xml rename to hello-swift-raw-jni/src/main/res/drawable/ic_launcher_foreground.xml diff --git a/hello-swift/src/main/res/layout/activity_main.xml b/hello-swift-raw-jni/src/main/res/layout/activity_main.xml similarity index 100% rename from hello-swift/src/main/res/layout/activity_main.xml rename to hello-swift-raw-jni/src/main/res/layout/activity_main.xml diff --git a/swift-java-hashing-example/hashing-app/src/main/res/mipmap-anydpi/ic_launcher.xml b/hello-swift-raw-jni/src/main/res/mipmap-anydpi/ic_launcher.xml similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/mipmap-anydpi/ic_launcher.xml rename to hello-swift-raw-jni/src/main/res/mipmap-anydpi/ic_launcher.xml diff --git a/swift-java-hashing-example/hashing-app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/hello-swift-raw-jni/src/main/res/mipmap-anydpi/ic_launcher_round.xml similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/mipmap-anydpi/ic_launcher_round.xml rename to hello-swift-raw-jni/src/main/res/mipmap-anydpi/ic_launcher_round.xml diff --git a/swift-java-hashing-example/hashing-app/src/main/res/mipmap-hdpi/ic_launcher.webp b/hello-swift-raw-jni/src/main/res/mipmap-hdpi/ic_launcher.webp similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/mipmap-hdpi/ic_launcher.webp rename to hello-swift-raw-jni/src/main/res/mipmap-hdpi/ic_launcher.webp diff --git a/swift-java-hashing-example/hashing-app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/hello-swift-raw-jni/src/main/res/mipmap-hdpi/ic_launcher_round.webp similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/mipmap-hdpi/ic_launcher_round.webp rename to hello-swift-raw-jni/src/main/res/mipmap-hdpi/ic_launcher_round.webp diff --git a/swift-java-hashing-example/hashing-app/src/main/res/mipmap-mdpi/ic_launcher.webp b/hello-swift-raw-jni/src/main/res/mipmap-mdpi/ic_launcher.webp similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/mipmap-mdpi/ic_launcher.webp rename to hello-swift-raw-jni/src/main/res/mipmap-mdpi/ic_launcher.webp diff --git a/swift-java-hashing-example/hashing-app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/hello-swift-raw-jni/src/main/res/mipmap-mdpi/ic_launcher_round.webp similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/mipmap-mdpi/ic_launcher_round.webp rename to hello-swift-raw-jni/src/main/res/mipmap-mdpi/ic_launcher_round.webp diff --git a/swift-java-hashing-example/hashing-app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/hello-swift-raw-jni/src/main/res/mipmap-xhdpi/ic_launcher.webp similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/mipmap-xhdpi/ic_launcher.webp rename to hello-swift-raw-jni/src/main/res/mipmap-xhdpi/ic_launcher.webp diff --git a/swift-java-hashing-example/hashing-app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/hello-swift-raw-jni/src/main/res/mipmap-xhdpi/ic_launcher_round.webp similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp rename to hello-swift-raw-jni/src/main/res/mipmap-xhdpi/ic_launcher_round.webp diff --git a/swift-java-hashing-example/hashing-app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/hello-swift-raw-jni/src/main/res/mipmap-xxhdpi/ic_launcher.webp similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/mipmap-xxhdpi/ic_launcher.webp rename to hello-swift-raw-jni/src/main/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/swift-java-hashing-example/hashing-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/hello-swift-raw-jni/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp rename to hello-swift-raw-jni/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp diff --git a/swift-java-hashing-example/hashing-app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/hello-swift-raw-jni/src/main/res/mipmap-xxxhdpi/ic_launcher.webp similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp rename to hello-swift-raw-jni/src/main/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/swift-java-hashing-example/hashing-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/hello-swift-raw-jni/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp rename to hello-swift-raw-jni/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp diff --git a/hello-swift/src/main/res/values-night/themes.xml b/hello-swift-raw-jni/src/main/res/values-night/themes.xml similarity index 100% rename from hello-swift/src/main/res/values-night/themes.xml rename to hello-swift-raw-jni/src/main/res/values-night/themes.xml diff --git a/swift-java-hashing-example/hashing-app/src/main/res/values/colors.xml b/hello-swift-raw-jni/src/main/res/values/colors.xml similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/values/colors.xml rename to hello-swift-raw-jni/src/main/res/values/colors.xml diff --git a/hello-swift/src/main/res/values/strings.xml b/hello-swift-raw-jni/src/main/res/values/strings.xml similarity index 100% rename from hello-swift/src/main/res/values/strings.xml rename to hello-swift-raw-jni/src/main/res/values/strings.xml diff --git a/hello-swift/src/main/res/values/themes.xml b/hello-swift-raw-jni/src/main/res/values/themes.xml similarity index 100% rename from hello-swift/src/main/res/values/themes.xml rename to hello-swift-raw-jni/src/main/res/values/themes.xml diff --git a/swift-java-hashing-example/hashing-app/src/main/res/xml/backup_rules.xml b/hello-swift-raw-jni/src/main/res/xml/backup_rules.xml similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/xml/backup_rules.xml rename to hello-swift-raw-jni/src/main/res/xml/backup_rules.xml diff --git a/swift-java-hashing-example/hashing-app/src/main/res/xml/data_extraction_rules.xml b/hello-swift-raw-jni/src/main/res/xml/data_extraction_rules.xml similarity index 100% rename from swift-java-hashing-example/hashing-app/src/main/res/xml/data_extraction_rules.xml rename to hello-swift-raw-jni/src/main/res/xml/data_extraction_rules.xml diff --git a/hello-swift/src/main/swift/.gitignore b/hello-swift-raw-jni/src/main/swift/.gitignore similarity index 100% rename from hello-swift/src/main/swift/.gitignore rename to hello-swift-raw-jni/src/main/swift/.gitignore diff --git a/hello-swift/src/main/swift/Package.swift b/hello-swift-raw-jni/src/main/swift/Package.swift similarity index 100% rename from hello-swift/src/main/swift/Package.swift rename to hello-swift-raw-jni/src/main/swift/Package.swift diff --git a/hello-swift/src/main/swift/Sources/helloswift/helloswift.swift b/hello-swift-raw-jni/src/main/swift/Sources/helloswift/helloswift.swift similarity index 100% rename from hello-swift/src/main/swift/Sources/helloswift/helloswift.swift rename to hello-swift-raw-jni/src/main/swift/Sources/helloswift/helloswift.swift diff --git a/settings.gradle.kts b/settings.gradle.kts index 813f6fc..0be2778 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -22,11 +22,17 @@ dependencyResolutionManagement { } rootProject.name = "Swift Android Examples" -include(":hello-swift") -include(":hello-swift-callback") -include(":hello-swift-library") + +// swift-java examples +include(":hello-swift-java-hashing-lib") +project(":hello-swift-java-hashing-lib").projectDir = file("hello-swift-java/hashing-lib") +include(":hello-swift-java-hashing-app") +project(":hello-swift-java-hashing-app").projectDir = file("hello-swift-java/hashing-app") + +// raw-jni examples +include(":hello-swift-raw-jni") +include(":hello-swift-raw-jni-callback") +include(":hello-swift-raw-jni-library") + +// native-only examples include(":native-activity") -include(":hashing-lib") -project(":hashing-lib").projectDir = file("swift-java-hashing-example/hashing-lib") -include(":hashing-app") -project(":hashing-app").projectDir = file("swift-java-hashing-example/hashing-app") From dd1431b9a123e193a49c88b2f11b9b39a3de4cf7 Mon Sep 17 00:00:00 2001 From: Andrew Druk Date: Tue, 28 Oct 2025 22:07:24 +0200 Subject: [PATCH 02/16] Update instruction for hashing library --- hello-swift-java/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hello-swift-java/README.md b/hello-swift-java/README.md index edd512a..70d8830 100644 --- a/hello-swift-java/README.md +++ b/hello-swift-java/README.md @@ -80,7 +80,7 @@ Next, let's prepare and publish the swift-java support libraries: 1. Run the Gradle assemble command from the root directory. This will compile the Swift code for all supported Android ABIs (arm64-v8a, armeabi-v7a, x86_64), run the `jextract` plugin, and package everything into an `.aar` file. ```bash - ./gradlew :hashing-lib:assembleRelease + ./gradlew :hello-swift-java-hashing-lib:assembleRelease ``` 3. After a successful build, the Android library will be located at `swift-java-hashing-example/hashing-lib/build/outputs/aar/hashing-lib-release.aar`. From 23dd04cd3693b615a2fbbcea05b0e683a6e81fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=C3=B3rio=20Gevartosky=20Torrezan?= Date: Wed, 29 Oct 2025 07:47:12 -0300 Subject: [PATCH 03/16] Update build.gradle.kts Importing swiftkit-core dependency --- hello-swift-java/hashing-app/build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hello-swift-java/hashing-app/build.gradle.kts b/hello-swift-java/hashing-app/build.gradle.kts index bddfdc0..607f1f6 100644 --- a/hello-swift-java/hashing-app/build.gradle.kts +++ b/hello-swift-java/hashing-app/build.gradle.kts @@ -48,6 +48,7 @@ dependencies { implementation(libs.androidx.ui.graphics) implementation(libs.androidx.ui.tooling.preview) implementation(libs.androidx.material3) + implementation("org.swift.swiftkit:swiftkit-core:1.0-SNAPSHOT") implementation(project(":hello-swift-java-hashing-lib")) testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) @@ -56,4 +57,4 @@ dependencies { androidTestImplementation(libs.androidx.ui.test.junit4) debugImplementation(libs.androidx.ui.tooling) debugImplementation(libs.androidx.ui.test.manifest) -} \ No newline at end of file +} From 6b3ba456a469108ac43a7110af3ffd48868b8b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=C3=B3rio=20Gevartosky=20Torrezan?= Date: Sat, 1 Nov 2025 16:16:38 -0300 Subject: [PATCH 04/16] Including SwiftJavaRuntimeSupport on SwiftHashing dependencies. Including SwiftJavaRuntimeSupport in the dependency list as it seems to be imported by swift generated files. Building the hashing-lib example the following error is throwing ``` [125/128] Compiling SwiftHashing SwiftHashing.swift 7 | import SwiftJava 8 | import CSwiftJavaJNI 9 | import SwiftJavaRuntimeSupport | `- error: no such module 'SwiftJavaRuntimeSupport' 10 | ``` --- hello-swift-java/hashing-lib/Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/hello-swift-java/hashing-lib/Package.swift b/hello-swift-java/hashing-lib/Package.swift index a28d581..1b21050 100644 --- a/hello-swift-java/hashing-lib/Package.swift +++ b/hello-swift-java/hashing-lib/Package.swift @@ -60,6 +60,7 @@ let package = Package( .product(name: "Crypto", package: "swift-crypto"), .product(name: "SwiftJava", package: "swift-java"), .product(name: "CSwiftJavaJNI", package: "swift-java"), + .product(name: "SwiftJavaRuntimeSupport", package: "swift-java"), ], swiftSettings: [ .unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"], .when(platforms: [.macOS, .linux, .windows])) From af0d3a82c6e2d7c092f31f3ce2f220e90cdaf056 Mon Sep 17 00:00:00 2001 From: Mads Odgaard Date: Sat, 1 Nov 2025 21:14:42 +0100 Subject: [PATCH 05/16] update hashing example to 17 --- hello-swift-java/hashing-app/build.gradle.kts | 6 +++--- hello-swift-java/hashing-lib/build.gradle | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hello-swift-java/hashing-app/build.gradle.kts b/hello-swift-java/hashing-app/build.gradle.kts index 607f1f6..e087f09 100644 --- a/hello-swift-java/hashing-app/build.gradle.kts +++ b/hello-swift-java/hashing-app/build.gradle.kts @@ -28,11 +28,11 @@ android { } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = "11" + jvmTarget = "17" } buildFeatures { compose = true diff --git a/hello-swift-java/hashing-lib/build.gradle b/hello-swift-java/hashing-lib/build.gradle index 818f756..f0170c9 100644 --- a/hello-swift-java/hashing-lib/build.gradle +++ b/hello-swift-java/hashing-lib/build.gradle @@ -14,11 +14,11 @@ android { defaultConfig { minSdkVersion 28 } -} -java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } } dependencies { From 23adeffbb202d872ee2e4e512093048c7fdcc2e5 Mon Sep 17 00:00:00 2001 From: Gaurav Chandarana Date: Sun, 2 Nov 2025 14:36:09 +0000 Subject: [PATCH 06/16] Update installation links in README.md (#9) --- hello-swift-raw-jni-callback/README.md | 4 ++-- hello-swift-raw-jni-library/README.md | 4 ++-- hello-swift-raw-jni/README.md | 4 ++-- native-activity/README.md | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hello-swift-raw-jni-callback/README.md b/hello-swift-raw-jni-callback/README.md index 065c995..8ca0413 100644 --- a/hello-swift-raw-jni-callback/README.md +++ b/hello-swift-raw-jni-callback/README.md @@ -16,8 +16,8 @@ The project consists of: Before you can build and run this project, you need to have the following installed: * **Java Development Kit (JDK)**: We recommend using JDK 21. Ensure the `JAVA_HOME` environment variable is set to your JDK installation path. -* **Swiftly**: You need to install [Swiftly](https://www.swift.org/install/) -* **Swift SDK for Android**: You need to install the [Swift SDK for Android](https://swift.org/install) +* **Swiftly**: You need to install [Swiftly](https://www.swift.org/swiftly/documentation/swiftly/getting-started/) +* **Swift SDK for Android**: You need to install the [Swift SDK for Android](https://www.swift.org/documentation/articles/swift-sdk-for-android-getting-started.html) ## Running the example diff --git a/hello-swift-raw-jni-library/README.md b/hello-swift-raw-jni-library/README.md index 564d8b6..10f6e9b 100644 --- a/hello-swift-raw-jni-library/README.md +++ b/hello-swift-raw-jni-library/README.md @@ -14,8 +14,8 @@ The project consists of: Before you can build and run this project, you need to have the following installed: * **Java Development Kit (JDK)**: We recommend using JDK 25. Ensure the `JAVA_HOME` environment variable is set to your JDK installation path. -* **Swiftly**: You need to install [Swiftly](https://www.swift.org/install/) -* **Swift SDK for Android**: You need to install the [Swift SDK for Android](https://swift.org/install) +* **Swiftly**: You need to install [Swiftly](https://www.swift.org/swiftly/documentation/swiftly/getting-started/) +* **Swift SDK for Android**: You need to install the [Swift SDK for Android](https://www.swift.org/documentation/articles/swift-sdk-for-android-getting-started.html) ## Building the library diff --git a/hello-swift-raw-jni/README.md b/hello-swift-raw-jni/README.md index f1a1fe1..330fba2 100644 --- a/hello-swift-raw-jni/README.md +++ b/hello-swift-raw-jni/README.md @@ -16,8 +16,8 @@ The project consists of: Before you can build and run this project, you need to have the following installed: * **Java Development Kit (JDK)**: We recommend using JDK 25. Ensure the `JAVA_HOME` environment variable is set to your JDK installation path. -* **Swiftly**: You need to install [Swiftly](https://www.swift.org/install/) -* **Swift SDK for Android**: You need to install the [Swift SDK for Android](https://swift.org/install) +* **Swiftly**: You need to install [Swiftly](https://www.swift.org/swiftly/documentation/swiftly/getting-started/) +* **Swift SDK for Android**: You need to install the [Swift SDK for Android](https://www.swift.org/documentation/articles/swift-sdk-for-android-getting-started.html) ## Running the example diff --git a/native-activity/README.md b/native-activity/README.md index 4d76082..e4134e3 100644 --- a/native-activity/README.md +++ b/native-activity/README.md @@ -16,8 +16,8 @@ The project consists of: Before you can build and run this project, you need to have the following installed: * **Java Development Kit (JDK)**: We recommend using JDK 25. Ensure the `JAVA_HOME` environment variable is set to your JDK installation path. -* **Swiftly**: You need to install [Swiftly](https://www.swift.org/install/) -* **Swift SDK for Android**: You need to install the [Swift SDK for Android](https://swift.org/install) +* **Swiftly**: You need to install [Swiftly](https://www.swift.org/swiftly/documentation/swiftly/getting-started/) +* **Swift SDK for Android**: You need to install the [Swift SDK for Android](https://www.swift.org/documentation/articles/swift-sdk-for-android-getting-started.html) * **Device/emulator with OpenGL ES support** ## Running the example From 23daf3a2f41f84802273c2d14873b4a4bf1c976c Mon Sep 17 00:00:00 2001 From: kk-777-1127 Date: Wed, 5 Nov 2025 19:53:14 +0900 Subject: [PATCH 07/16] Optimize imports in MainActivity.kt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove unused imports to improve code cleanliness: - Remove androidx.compose.material3.Scaffold - Remove androidx.compose.ui.tooling.preview.Preview - Remove androidx.compose.ui.unit.sp 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../src/main/java/com/example/hashingapp/MainActivity.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/hello-swift-java/hashing-app/src/main/java/com/example/hashingapp/MainActivity.kt b/hello-swift-java/hashing-app/src/main/java/com/example/hashingapp/MainActivity.kt index 3ac0265..24cd5c8 100644 --- a/hello-swift-java/hashing-app/src/main/java/com/example/hashingapp/MainActivity.kt +++ b/hello-swift-java/hashing-app/src/main/java/com/example/hashingapp/MainActivity.kt @@ -24,7 +24,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.material3.TextField @@ -33,9 +32,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import com.example.hashingapp.ui.theme.HashingAppTheme import com.example.swifthashing.SwiftHashing From 770193b07f2ca2c72532c9c7bb60ef12f3f9820c Mon Sep 17 00:00:00 2001 From: Finagolfin Date: Tue, 28 Oct 2025 17:07:49 +0530 Subject: [PATCH 08/16] Update README to push swift-java as the recommended approach Also, showcase the pure Swift example separately. --- README.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 02053fc..daa278a 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,25 @@ # Swift Android Examples -This repository contains example applications that demonstrate how to use the [Swift SDK for Android](https://swift.org/install). Each example showcases different integration patterns for Swift on Android. +This repository contains example applications that demonstrate how to use the +[Swift SDK for Android](https://swift.org/install). Each example showcases different +integration patterns for Swift on Android. It is highly recommended that you use +the automated swift-java interop that generates bindings for you; the others are +merely provided as examples for those who want to dig deeper and see the raw JNI, +or not use Java at all. ## Available Examples -Examples using [swift-java](https://github.com/swiftlang/swift-java) to generate necessary Swift/Java bridging: -- **[hello-swift-java](hello-swift-java/)** - application that demonstrates how to call Swift code from an Android app with automatically generated Java wrappers and JNI code using [swift-java](https://github.com/swiftlang/swift-java). +Examples using [swift-java](https://github.com/swiftlang/swift-java) to generate +the necessary Swift/Java bridging: +- **[hello-swift-java](hello-swift-java/)** - application that demonstrates how +to call Swift code from an Android app with automatically generated Java wrappers +and JNI code. + +An example of a purely native Swift app, which calls no Java APIs: +- **[native-activity](native-activity/)** - complete native Android activity with +OpenGL ES rendering written entirely in Swift. Examples using raw JNI, without generated bridging sources: - **[hello-swift-raw-jni](hello-swift-raw-jni/)** - basic Swift integration that calls a Swift function. - **[hello-swift-raw-jni-callback](hello-swift-raw-jni-callback/)** - demonstrates bidirectional communication with Swift timer callbacks updating Android UI. - **[hello-swift-raw-jni-library](hello-swift-raw-jni-library/)** - shows how to package Swift code as a reusable Android library component. -- **[native-activity](native-activity/)** - complete native Android activity with OpenGL ES rendering written entirely in Swift. From d2ed09d89a0a9a2108a36f529c003cc43482c984 Mon Sep 17 00:00:00 2001 From: kk-777-1127 Date: Wed, 5 Nov 2025 19:31:18 +0900 Subject: [PATCH 09/16] Fix typo in JAVA_HOME path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove duplicate slash in JAVA_HOME path. The correct path should be `${HOME}/.sdkman/candidates/java/current` instead of `${HOME}//.sdkman/candidates/java/current`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- hello-swift-java/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hello-swift-java/README.md b/hello-swift-java/README.md index 70d8830..c48c743 100644 --- a/hello-swift-java/README.md +++ b/hello-swift-java/README.md @@ -48,7 +48,7 @@ Now restart the terminal so that the `sdk` utility is added to your path, and th ```bash sdk install java 25.0.1-amzn --use # only in order to publish swift-java artifacts locally -export JAVA_HOME="${HOME}//.sdkman/candidates/java/current" +export JAVA_HOME="${HOME}/.sdkman/candidates/java/current" ``` Next, let's prepare and publish the swift-java support libraries: From 8eb923b636c7908a38355f72ff017107e1596f02 Mon Sep 17 00:00:00 2001 From: Tim Sneath Date: Tue, 28 Oct 2025 14:38:25 -0700 Subject: [PATCH 10/16] Expand opening text --- README.md | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index daa278a..5224689 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,38 @@ This repository contains example applications that demonstrate how to use the [Swift SDK for Android](https://swift.org/install). Each example showcases different -integration patterns for Swift on Android. It is highly recommended that you use -the automated swift-java interop that generates bindings for you; the others are -merely provided as examples for those who want to dig deeper and see the raw JNI, -or not use Java at all. +integration patterns for Swift on Android. -## Available Examples +## Getting Started + +The **[hello-swift-java](hello-swift-java/)** example is the recommended +approach for integrating Swift into Android applications. This example +demonstrates how to build a Swift library that can be seamlessly called from +Kotlin/Java code using [swift-java](https://github.com/swiftlang/swift-java), +which automatically generates the necessary Java wrappers and JNI bindings for +you. + +The example consists of two components: + +- **hashing-lib**: A Swift package that uses `swift-crypto` to provide SHA256 + hashing functionality +- **hashing-app**: A Kotlin Android app using Jetpack Compose UI that calls the + Swift library + +When you press the "Hash" button in the app, it calls directly from Kotlin into +Swift code to compute a SHA256 hash—no manual JNI code required. The swift-java +tooling handles all the bridging automatically, making it easy to expose Swift +APIs to your Android application with type safety and minimal boilerplate. + +This approach is ideal for production applications where you want to write +business logic, algorithms, or libraries in Swift while maintaining a standard +Kotlin/Java Android frontend. + +## Other Examples + +For those who want to explore alternative integration patterns or understand +lower level details of how Swift integrates with Android, there are a number of +other examples provided. Examples using [swift-java](https://github.com/swiftlang/swift-java) to generate the necessary Swift/Java bridging: From 66e32bf40ba1e9ece8a9d65b144ef4ce7c0d863c Mon Sep 17 00:00:00 2001 From: finagolfin Date: Wed, 5 Nov 2025 21:39:47 +0530 Subject: [PATCH 11/16] Update README.md to remove redundant link and fix some copy --- README.md | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5224689..795ccf3 100644 --- a/README.md +++ b/README.md @@ -25,21 +25,15 @@ Swift code to compute a SHA256 hash—no manual JNI code required. The swift-jav tooling handles all the bridging automatically, making it easy to expose Swift APIs to your Android application with type safety and minimal boilerplate. -This approach is ideal for production applications where you want to write -business logic, algorithms, or libraries in Swift while maintaining a standard -Kotlin/Java Android frontend. +This approach is ideal for production Android applications where you want to write +business logic, algorithms, or libraries in Swift, while maintaining a standard +Kotlin/Java frontend. ## Other Examples For those who want to explore alternative integration patterns or understand -lower level details of how Swift integrates with Android, there are a number of -other examples provided. - -Examples using [swift-java](https://github.com/swiftlang/swift-java) to generate -the necessary Swift/Java bridging: -- **[hello-swift-java](hello-swift-java/)** - application that demonstrates how -to call Swift code from an Android app with automatically generated Java wrappers -and JNI code. +lower-level details of how Swift integrates with Android, there are a number of +more manual examples provided. An example of a purely native Swift app, which calls no Java APIs: - **[native-activity](native-activity/)** - complete native Android activity with From 98da59d950579abcb626fe747d9911526dd4496d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=C3=B3rio=20Gevartosky=20Torrezan?= Date: Thu, 6 Nov 2025 18:15:44 -0400 Subject: [PATCH 12/16] [README.md] Introducing `Exploring swift-java` and `troubleshooting` sections --- hello-swift-java/README.md | 51 +++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/hello-swift-java/README.md b/hello-swift-java/README.md index c48c743..bd1e420 100644 --- a/hello-swift-java/README.md +++ b/hello-swift-java/README.md @@ -83,4 +83,53 @@ Next, let's prepare and publish the swift-java support libraries: ./gradlew :hello-swift-java-hashing-lib:assembleRelease ``` -3. After a successful build, the Android library will be located at `swift-java-hashing-example/hashing-lib/build/outputs/aar/hashing-lib-release.aar`. +2. After a successful build, the Android library will be located at `swift-java-hashing-example/hashing-lib/build/outputs/aar/hashing-lib-release.aar`. + + +## Exploring `swift-java` +We encourage exploring `swift-java` by writing Swift code to the file `hello-swift-java/hashing-lib/Sources/SwiftHashing/SwiftHashing.swift` and building the `hashing-app` target. + +Once the `hashing-app` build completes, the newly generated Java code will be available to use in the Android project. + +While exploring, some errors might occur. Following is a list of errors and how to troubleshoot them. +>⚠️⚠️ These are temporary and will not be required once the gradle plugin is automated ⚠️⚠️ + +___ +### Swift/Java not available for use once Android build completes: +If after adding new code to `SwiftHashing.swift` the same is not available on Android after a build, please delete the swift `.build` folder located at `hello-swift-java/hashing-lib/.build` (Attention to the dot before the folder name `.build`) + +Build the Android `hashing-app` target again and the code should be avilable. + +--- +### Crash: Library not found +If the code added to `SwiftHashing.swift` introduces a new library dependency, and the app is crashing with the following error:\ +`Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libswiftObservation.so" not found` +1. Locate the file `build.gradle (Module :hello-swift-java-hashing-lib` +2. Locate the defined list of libraries `def swiftRuntimeLibs` +3. Include the library specified in the error message + +In the example log above, `Observation` cannot be found. This is how the `swiftRuntimeLibs` show look after including the missing library. +``` +def swiftRuntimeLibs = [ + "swiftCore", + "swift_Concurrency", + "swift_StringProcessing", + "swift_RegexParser", + "swift_Builtin_float", + "swift_math", + "swiftAndroid", + "dispatch", + "BlocksRuntime", + "swiftSwiftOnoneSupport", + "swiftDispatch", + "Foundation", + "FoundationEssentials", + "FoundationInternationalization", + "_FoundationICU", + "swiftSynchronization", + "swiftObservation", <===================== NEW LIBRARY +] +``` + + + From 165b44790574d6fcfb584a7cfaa006d3b6113460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=C3=B3rio=20Gevartosky=20Torrezan?= Date: Thu, 6 Nov 2025 18:35:54 -0400 Subject: [PATCH 13/16] Update README.md --- hello-swift-java/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hello-swift-java/README.md b/hello-swift-java/README.md index bd1e420..384682d 100644 --- a/hello-swift-java/README.md +++ b/hello-swift-java/README.md @@ -87,7 +87,11 @@ Next, let's prepare and publish the swift-java support libraries: ## Exploring `swift-java` -We encourage exploring `swift-java` by writing Swift code to the file `hello-swift-java/hashing-lib/Sources/SwiftHashing/SwiftHashing.swift` and building the `hashing-app` target. +We encourage exploring `swift-java` by writing Swift code to the file `hello-swift-java/hashing-lib/Sources/SwiftHashing/SwiftHashing.swift` and building the `hashing-app` target.\ +> [!TIP] +> The list of supported features can be found at:\ +> https://swiftpackageindex.com/swiftlang/swift-java/main/documentation/swiftjavadocumentation/supportedfeatures#JExtract-calling-Swift-from-Java\ + Once the `hashing-app` build completes, the newly generated Java code will be available to use in the Android project. From eaee02d2f96d6fdd8545536c55b6fc661e0a3079 Mon Sep 17 00:00:00 2001 From: Thomas Krajacic Date: Fri, 7 Nov 2025 09:33:50 +0100 Subject: [PATCH 14/16] Add v5 language mode flag --- hello-swift-java/hashing-lib/Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/hello-swift-java/hashing-lib/Package.swift b/hello-swift-java/hashing-lib/Package.swift index 1b21050..0295118 100644 --- a/hello-swift-java/hashing-lib/Package.swift +++ b/hello-swift-java/hashing-lib/Package.swift @@ -63,6 +63,7 @@ let package = Package( .product(name: "SwiftJavaRuntimeSupport", package: "swift-java"), ], swiftSettings: [ + .swiftLanguageMode(.v5), .unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"], .when(platforms: [.macOS, .linux, .windows])) ], plugins: [ From 4d81a1b1fd5c45edd7bc7d277ce4f4832c6424f6 Mon Sep 17 00:00:00 2001 From: Konrad `ktoso` Malawski Date: Fri, 7 Nov 2025 18:49:56 +0900 Subject: [PATCH 15/16] Apply suggestions from code review Co-authored-by: Mads Odgaard --- hello-swift-java/README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hello-swift-java/README.md b/hello-swift-java/README.md index 384682d..bf923aa 100644 --- a/hello-swift-java/README.md +++ b/hello-swift-java/README.md @@ -95,18 +95,21 @@ We encourage exploring `swift-java` by writing Swift code to the file `hello-swi Once the `hashing-app` build completes, the newly generated Java code will be available to use in the Android project. -While exploring, some errors might occur. Following is a list of errors and how to troubleshoot them. ->⚠️⚠️ These are temporary and will not be required once the gradle plugin is automated ⚠️⚠️ +## Troubleshooting + +> Most of these issues are temporary and will be resolved in the future as the swift-java project matures and automates more of the build steps. + ___ -### Swift/Java not available for use once Android build completes: +### New Swift Code is not available in Java once Android build completes: If after adding new code to `SwiftHashing.swift` the same is not available on Android after a build, please delete the swift `.build` folder located at `hello-swift-java/hashing-lib/.build` (Attention to the dot before the folder name `.build`) -Build the Android `hashing-app` target again and the code should be avilable. +Build the Android `hashing-app` target again and the Swift API should be available in Java. +If the code is still not available, the `swift-java` project might not support the specific Swift code. Please make sure the feature is listed as supported in the [Supported Features](https://swiftpackageindex.com/swiftlang/swift-java/main/documentation/swiftjavadocumentation/supportedfeatures#JExtract-calling-Swift-from-Java) documentation. --- -### Crash: Library not found -If the code added to `SwiftHashing.swift` introduces a new library dependency, and the app is crashing with the following error:\ +#### Crash: Library not found +If the code added to `SwiftHashing.swift` introduces a new library dependency, forexample `import Observation`, and the app crashes with the following error:\ `Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libswiftObservation.so" not found` 1. Locate the file `build.gradle (Module :hello-swift-java-hashing-lib` 2. Locate the defined list of libraries `def swiftRuntimeLibs` From 92a181a10af2e8b50b05783035d3ae1cc98326da Mon Sep 17 00:00:00 2001 From: Konrad `ktoso` Malawski Date: Fri, 7 Nov 2025 18:50:57 +0900 Subject: [PATCH 16/16] Apply suggestions from code review --- hello-swift-java/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/hello-swift-java/README.md b/hello-swift-java/README.md index bf923aa..f913387 100644 --- a/hello-swift-java/README.md +++ b/hello-swift-java/README.md @@ -100,14 +100,12 @@ Once the `hashing-app` build completes, the newly generated Java code will be av > Most of these issues are temporary and will be resolved in the future as the swift-java project matures and automates more of the build steps. -___ ### New Swift Code is not available in Java once Android build completes: If after adding new code to `SwiftHashing.swift` the same is not available on Android after a build, please delete the swift `.build` folder located at `hello-swift-java/hashing-lib/.build` (Attention to the dot before the folder name `.build`) Build the Android `hashing-app` target again and the Swift API should be available in Java. If the code is still not available, the `swift-java` project might not support the specific Swift code. Please make sure the feature is listed as supported in the [Supported Features](https://swiftpackageindex.com/swiftlang/swift-java/main/documentation/swiftjavadocumentation/supportedfeatures#JExtract-calling-Swift-from-Java) documentation. ---- #### Crash: Library not found If the code added to `SwiftHashing.swift` introduces a new library dependency, forexample `import Observation`, and the app crashes with the following error:\ `Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libswiftObservation.so" not found`