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 01/14] 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 02/14] 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 03/14] 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 04/14] 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 05/14] 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 06/14] 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 07/14] 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 08/14] 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 09/14] 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 10/14] [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 11/14] 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 12/14] 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 13/14] 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 14/14] 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`