Skip to content

Commit 1dd6183

Browse files
authored
Merge pull request #21 from gevartosky/patch-3
2 parents f551fce + 92a181a commit 1dd6183

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

hello-swift-java/README.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,58 @@ 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+
> [!TIP]
92+
> The list of supported features can be found at:\
93+
> https://swiftpackageindex.com/swiftlang/swift-java/main/documentation/swiftjavadocumentation/supportedfeatures#JExtract-calling-Swift-from-Java\
94+
95+
96+
Once the `hashing-app` build completes, the newly generated Java code will be available to use in the Android project.
97+
98+
## Troubleshooting
99+
100+
> 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.
101+
102+
103+
### New Swift Code is not available in Java once Android build completes:
104+
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`)
105+
106+
Build the Android `hashing-app` target again and the Swift API should be available in Java.
107+
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.
108+
109+
#### Crash: Library not found
110+
If the code added to `SwiftHashing.swift` introduces a new library dependency, forexample `import Observation`, and the app crashes with the following error:\
111+
`Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libswiftObservation.so" not found`
112+
1. Locate the file `build.gradle (Module :hello-swift-java-hashing-lib`
113+
2. Locate the defined list of libraries `def swiftRuntimeLibs`
114+
3. Include the library specified in the error message
115+
116+
In the example log above, `Observation` cannot be found. This is how the `swiftRuntimeLibs` show look after including the missing library.
117+
```
118+
def swiftRuntimeLibs = [
119+
"swiftCore",
120+
"swift_Concurrency",
121+
"swift_StringProcessing",
122+
"swift_RegexParser",
123+
"swift_Builtin_float",
124+
"swift_math",
125+
"swiftAndroid",
126+
"dispatch",
127+
"BlocksRuntime",
128+
"swiftSwiftOnoneSupport",
129+
"swiftDispatch",
130+
"Foundation",
131+
"FoundationEssentials",
132+
"FoundationInternationalization",
133+
"_FoundationICU",
134+
"swiftSynchronization",
135+
"swiftObservation", <===================== NEW LIBRARY
136+
]
137+
```
138+
139+
140+

0 commit comments

Comments
 (0)