Skip to content

Commit 98da59d

Browse files
authored
[README.md] Introducing Exploring swift-java and troubleshooting sections
1 parent abe51e7 commit 98da59d

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

hello-swift-java/README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,53 @@ Next, let's prepare and publish the swift-java support libraries:
8383
./gradlew :hello-swift-java-hashing-lib:assembleRelease
8484
```
8585

86-
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`.
86+
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`.
87+
88+
89+
## Exploring `swift-java`
90+
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.
91+
92+
Once the `hashing-app` build completes, the newly generated Java code will be available to use in the Android project.
93+
94+
While exploring, some errors might occur. Following is a list of errors and how to troubleshoot them.
95+
>⚠️⚠️ These are temporary and will not be required once the gradle plugin is automated ⚠️⚠️
96+
97+
___
98+
### Swift/Java not available for use once Android build completes:
99+
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`)
100+
101+
Build the Android `hashing-app` target again and the code should be avilable.
102+
103+
---
104+
### Crash: Library not found
105+
If the code added to `SwiftHashing.swift` introduces a new library dependency, and the app is crashing with the following error:\
106+
`Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libswiftObservation.so" not found`
107+
1. Locate the file `build.gradle (Module :hello-swift-java-hashing-lib`
108+
2. Locate the defined list of libraries `def swiftRuntimeLibs`
109+
3. Include the library specified in the error message
110+
111+
In the example log above, `Observation` cannot be found. This is how the `swiftRuntimeLibs` show look after including the missing library.
112+
```
113+
def swiftRuntimeLibs = [
114+
"swiftCore",
115+
"swift_Concurrency",
116+
"swift_StringProcessing",
117+
"swift_RegexParser",
118+
"swift_Builtin_float",
119+
"swift_math",
120+
"swiftAndroid",
121+
"dispatch",
122+
"BlocksRuntime",
123+
"swiftSwiftOnoneSupport",
124+
"swiftDispatch",
125+
"Foundation",
126+
"FoundationEssentials",
127+
"FoundationInternationalization",
128+
"_FoundationICU",
129+
"swiftSynchronization",
130+
"swiftObservation", <===================== NEW LIBRARY
131+
]
132+
```
133+
134+
135+

0 commit comments

Comments
 (0)