or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
Cargo-mobile for Wry
We evaluate cargo-mobile to create a mobile project for both Xcode and Android studio.Right now it provides two templates
tauri
(iOS only at the moment) andwry
(both iOS and Android).Prerequisite
Setting up Android Environment
1. Installing JDK
Using Android Studio:
If you have Android Studio installed, it ships with a version of JDK so you don't have to install it manually. It is usually at
<location of android studio installation>/jre
and can be used forJAVA_HOME
env var.Using the terminal:
Linux/WSL
Install it by running the following command based on your distro to install JDK:
Set the
JAVA_HOME
env variable for this current shell (we will make it permanent later on)macOS
JAVA_HOME
env:Windows
JAVA_HOME
env variable for this current shell (we will make it permanent later on)2. Installing Android SDK and NDK
There is two ways to install the sdk and ndk.
Using Android Studio:
You can use the SDK Manager in Android Studio to install:
Using the terminal:
If you don't want or can't use Android Studio you can still get the SDK Manager cli quite easily and use it to install other components.
Linux/WSL/macOS
Download the
cmdline-tools
Install required SDK and NDK components
Windows
Download the
cmdline-tools
Install required SDK and NDK components
3. Setting up Environment Variables
You'll need to set up some environment variables to get everything to work properly. The environment variables below should be all the ones your need to be able to use cargo-mobile to build/run your android app.
Linux/WSL/macOS
After updating
.bashrc
either runsource ~/.bashrc
or reopen your terminal to apply the changes.Windows
Open a powershell instance and run the following commands in order
You should now have all the environment variables required and the cmdline-tools available in your PATH. You can verify this by running
sdkmanager
which should now be showing its help info.4. Install Rust android targets:
Getting Started
Now lets bootstrap a project to develop a tauri or wry project for mobile.
Build and Run on Device
Android
cargo android run
iOS
cargo apple run
First time running the app will be blocked. Go to your phone's
Settings > Privacy & Security > Developer Mode
to enable developer mode.Settings -> General -> VPN and device management -> From "Developer App"
section found "Apple Development: APPLE_ID" -> TrustBuild and Run on Emulator
Android
Using Android Studio
cargo android open
Trust Project
,Use Embedded JDK
abiFilters += listOf("arm64-v8a")
undercreate("arm")
branch in:app
's 'build.gradle.kts
.Device supports x86, but APK only supports armeabi-v7a
then check this Stack Overflow answer to fix it.Without Android Studio
If you don't have access to Android Studio or don't want or when running in WSL, you can build and run the generated project directly from the terminal
iOS
cargo build --target x86_64-apple-ios
cargo build --target aarch64-apple-ios-sim
cargo apple open
Custom Protocols
Android
Same as others.
TODO: add how does its scheme actually looks like.
iOS
Same as macOS.
To get the path of your assets, you can call
CFBundle::resources_path
. So url likewry://assets/index.html
could get the html file in assets directory.IPC
Both support
ipc.PostMessage()
.Devtools
Set
devtools
attribute to true when building webview.Android
Open
chrome://inspect/#devices
in Chrome to get the devtools window.iOS
Open Safari > Develop > [Your Device Name] > [Your WebView].