Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

How to build on mobile for both iOS and Android? #226

Closed
thangchq-ibl opened this issue Aug 23, 2018 · 7 comments
Closed

How to build on mobile for both iOS and Android? #226

thangchq-ibl opened this issue Aug 23, 2018 · 7 comments

Comments

@thangchq-ibl
Copy link

Hi everyone,
Currently we are developing a mobile wallet using React Native for iOS and Android. And we really love to support Cardano in our wallet.
Please let us know which is the better way:

  1. Run cardano wasm binding for JavaScript on React Native. (We tried and failed to build, any suggestion?)
  2. Compile rust cardano to native library (iOS and Android); then write bridges of them for React Native.

Your help is much appreciated,
Best regards.

@NicolasDP
Copy link
Contributor

Hi @thangchq-ibl ,

  1. there is a build script in the cardano wasm binding repo did you use it? Could you open an issue in this repo so we can work there to help you build JS bindings, adding logs and other information to help us reproduce the issue would be very helpful too.
  2. it is possible to compile to iOS or Android. we have started a c binding library in cardano-c. However the APIs is not stabilized and is not thoroughly tested.

@thangchq-ibl
Copy link
Author

Thank you very much @NicolasDP for your reply. We are are trying the 2nd approach at the moment following this guideline. Will ask for help again if needed.

@NicolasDP
Copy link
Contributor

If it helps, you can try cargo lipo subcommand. It might simplify your life to compile the library for iOS.

For android you could try cargo apk too.

I haven't tried them yet. But It seems it could work better than the build script provided in the cardano-c directory.

@Captainkoko
Copy link

Hi @NicolasDP ,
Thanks for your diligent support. We were able to compile for native iOS and Android. But problem is there are many core functions missing at the moment....
Any suggestion we can overcome the dire situation?

Best regards,
Jackie Pham

@thangchq-ibl
Copy link
Author

thangchq-ibl commented Aug 28, 2018

Hi @NicolasDP,
I tried to build *.so for Android from cardano-c by config Cargo.toml (config reference) using cdylib:

[package]
name = "cardano-c"
version = "0.1.0"
authors = ["Nicolas Di Prima <nicolas.diprima@iohk.io>", "Vincent Hanquez <vincent.hanquez@iohk.io>"]

[lib]
crate-type = ["cdylib" ]

[dependencies]
cardano = { path = "../cardano" }

But I meet errors:

./build.sh armv7-linux-androideabi
## compile library for target: `armv7-linux-androideabi'

 * toolchain's target `armv7-linux-androideabi' already installed
 * compiling with debug symbols
warning: unused import: `cardano::config`
 --> cardano-c/src/wallet.rs:5:5
  |
5 | use cardano::config;
  |     ^^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: unused import: `c_char`
 --> cardano-c/src/bip39.rs:1:27
  |
1 | use std::os::raw::{c_int, c_char};
  |                           ^^^^^^

warning: unused imports: `ffi`, `ptr`
 --> cardano-c/src/bip39.rs:2:11
  |
2 | use std::{ffi, slice, ptr};
  |           ^^^         ^^^

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack"

Can you have any suggestion? Or can I build cardano-c for .so file?

Many Thanks.

@NicolasDP
Copy link
Contributor

NicolasDP commented Aug 28, 2018

could you try to extract the linking error messages? (you might need to update the script to allow more verbosity).

Something like this would help maybe:

-    ${CARGO} build           --target=${TARGET} --quiet
+    ${CARGO} build           --target=${TARGET}

@NicolasDP
Copy link
Contributor

@Captainkoko feel free to pop in the #184 ticket, we welcome any contribution/help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants