/2023-SNU-Rust-CrossPlatform

2023년 서울대학교 컴퓨터공학부 특강 - Rust 크로스 플랫폼 프로그래밍 발표 자료 및 예제 코드

Primary LanguageRustMIT LicenseMIT

2023-SNU-Rust-CorssPlatform

2023년 서울대학교 컴퓨터공학부 특강 - Rust 크로스 플랫폼 프로그래밍 발표 자료 및 예제 코드

Contents

Prerequisite

  1. Install Rust.

Rust + iOS

  1. Install Xcode.

  2. Install Xcode Command Line Tools:

xcode-select --install
  1. Add iOS architectures to support cross-compile:
rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios
  1. Install cargo-lipo for making universal library easily:
cargo install cargo-lipo

Rust + WebAssembly

  1. Install wasm-pack for making WebAssembly binary file easily.

  2. Install node and npm using homebrew:

brew install node
  1. Install yarn using homebrew:
brew install yarn

Quick Start

Rust + iOS

  1. Run this command inside the rust-cross-ios directory:
cargo-lipo --release
  1. That's it! You can run iOS example in Xcode.

Rust + WebAssembly

  1. Run this command inside the rust-cross-web directory:
wasm-pack build
  1. Copy pkg folder to example-web directory.

WebAssembly with TypeScript

  1. Ensure that the local development server and its dependencies are installed by running this command within the example-web directory:
npm install
  1. Run this command from within the example-web directory:
npm run start
  1. Go to http://localhost:8080/

Generating Foreign-Language Bindings with UniFFI

Kotlin

cargo run --bin uniffi-bindgen generate src/calc.udl --language kotlin

Swift

cargo run --bin uniffi-bindgen generate src/calc.udl --language swift

References

How To Contribute

Contributions are always welcome, either reporting issues/bugs or forking the repository and then issuing pull requests when you have completed some additional coding that you feel will be beneficial to the main project. If you are interested in contributing in a more dedicated capacity, then please contact me.

Contact

You can contact me via e-mail (utilForever at gmail.com). I am always happy to answer questions or help with any issues you might have, and please be sure to share any additional work or your creations with me, I love seeing what other people are making.

License

The class is licensed under the MIT License:

Copyright © 2023 Chris Ohk.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.