Skip to content

Commit

Permalink
Improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ivnsch committed Aug 17, 2019
1 parent 708566e commit 4c43f65
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![logos](img/logos_.png)

This is an example that shows how to communicate with a shared Rust library from an Android and iOS app. The idea is to be able to share domain logic & most services (networking, database, bluetooth, etc.) with Rust and use the native SDKs for presentation and platform specific services.
This is an example that shows how to communicate with a shared Rust library from an Android and iOS app. The idea is to be able to share domain logic & most services (networking, database, bluetooth, etc.) using Rust and use the native SDKs for presentation and platform specific services.

# Supported

Expand Down Expand Up @@ -34,7 +34,7 @@ rustup toolchain list

The Rust sources are [here](src)

# ![android](img/android_.png) Android instructions
# ![android](img/android1.png) Android instructions

These steps show how to build and run an Android app in debug mode for a 64 bits emulator.

Expand All @@ -60,7 +60,7 @@ rustup target add x86_64-linux-android

### Add path to linker

- Update linker path in <project_root>/.cargo/config:
- Update linker path in [Cargo's config](.cargo/config).

```
[target.x86_64-linux-android]
Expand All @@ -81,7 +81,7 @@ linker = "<Directory where targets were installed (provided in environment varia

### Run

Ensure [adb](https://developer.android.com/studio/command-line/adb) is installed and the emulator or device open.
Ensure [adb](https://developer.android.com/studio/command-line/adb) is installed.

then:

Expand All @@ -95,17 +95,17 @@ Start the app in the emulator / device!

OR

Just run the project in Android Studio. This will build, install and run.
Run the project in Android Studio. This will build, install and run.

### Relevant configuration files

If you want to add targets or tweak the configuration, you have to edit one or more of these files:

- [App's Gradle config](app/build.gradle): This contains the apk settings (like application id, sdk version) and build steps. It builds for the provided architectures using cargo and puts the generated shared libraries (.so files) in the expected directories. If you want to build for a new target, add it [here](app/build.gradle#L45). The target's key is the [folder name where the shared library will be put](https://developer.android.com/ndk/guides/abis.html), and the value is the toolchain's name used by rustup.

- [Cargo config](.cargo/config): Contains linker and runner paths for targets.
- [Cargo config](.cargo/config): Contains linker paths for targets.

- [build.rs](build.rs): This is a script invoked by Cargo before everything else. For Android, it's used to tell [rust_swig](https://github.com/Dushistov/rust_swig) to generate the glue Rust files needed for Java interop. If you change the app's package structure / names, you have to update this file accordingly. It also sets the import to use for the `NonNull` annotation ( `use_null_annotation_from_package`). If you're using a recent Android SDK version, you don't need to change it.
- [build.rs](build.rs): This is a script invoked by Cargo before everything else. For Android, it's used to tell [rust_swig](https://github.com/Dushistov/rust_swig) to generate the glue files for Java interop. If you change the app's package structure / names, you have to update this file accordingly. It also sets the import to use for the `NonNull` annotation ( `use_null_annotation_from_package`). If you're using a recent Android SDK version, you don't need to change it.

### Updating Rust

Expand All @@ -119,7 +119,7 @@ You edited something in Rust! Now you have to:

The code of the Android app can be found [here](app). This is a regular Android app which you can work with normally. Just don't modify the generated JNI files and remember to update [build.rs](build.rs) as described in [Relevant configuration files](#relevant-configuration-files), if you change the package structure.

# ![iOS](img/ios_.png) iOS instructions
# ![iOS](img/ios1.png) iOS instructions

### App code

Expand All @@ -143,7 +143,7 @@ With the header and library in place, you can run the iOS app.

You edited something in Rust! Now you have to:

- Update the [C glue Rust implementation file](src/ios_c_headers.rs). Orient with the existing code. Differently to Android we have to write this glue manually, because there's no library like rust_swig.
- Update the [C glue Rust implementation file](src/ios_c_headers.rs). Orient with the existing code. Differently to Android the glue has to be written manually, because there's no library like rust_swig.

- Build as described in "Build & run". Cargo will invoke build.rs, which uses cbindgen to generate the iOS library files.

Expand Down
Binary file added img/android1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/android_.png
Binary file not shown.
Binary file added img/ios1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/ios_.png
Binary file not shown.

0 comments on commit 4c43f65

Please sign in to comment.