-
Notifications
You must be signed in to change notification settings - Fork 18
Expand opening text #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,18 +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. | ||
|
|
||
| ## Available Examples | ||
|
|
||
| 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. | ||
| integration patterns for Swift on Android. | ||
|
|
||
| ## 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. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about explaining the example in this README, just because we go in depth in each example's own README; I'd keep the main README pretty slim so we don't have to come back to it when working "in" a specific example and updating its own docs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do agree in general, but for this specific first example, I think it might be helpful to be a little more explicit. At least for myself, I read the main README and then cloned the project. I didn't even discover that there were per-project READMEs at first -- I just opened the most likely looking one in Android Studio. |
||
|
|
||
| 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 | ||
| 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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be good addition