Giter Site home page Giter Site logo

chrisballinger / rust-to-ios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wojteklu/rust-to-ios

0.0 3.0 0.0 5.37 MB

Example project for building a library for iOS in Rust.

License: MIT License

Swift 44.58% Objective-C 3.26% C 14.67% Rust 37.49%

rust-to-ios's Introduction

rust-to-ios

Swift 4.0 @wojteklu

Example project for building a library for iOS.

  • ✓ sending primitives between Rust and iOS
  • ✓ sending strings between Rust and iOS
  • ✓ giving ownership of a Rust instance to Swift

Setup

  1. Download rustup needed to setup Rust for cross-compiling.

    curl https://sh.rustup.rs -sSf | sh
  2. Download targets for iOS.

    rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios
  3. Install cargo-lipo to generate the iOS universal library.

    cargo install cargo-lipo

Building the library

  1. Create a new cargo project.

    cargo new message
  2. Update Cargo.toml by adding the [lib] section.

    [lib]
    name = "message"
    crate-type = ["staticlib"]
  3. Write the library and expose its public interface in a C header.

  4. Build the library.

    cd message
    
    cargo lipo --release

Using the library

  1. Create the iOS project.

  2. Add the C header to allow using the Rust functions from C.

  3. Copy target/universal/release/libmessage.a to project.

  4. Add libresolv.tbd to Linked frameworks and libraries.

  5. Note that cargo-lipo does not support bitcode yet. You must set ENABLE_BITCODE to NO.

Author

Wojtek Lukaszuk @wojteklu

License

Available under the MIT license. See the LICENSE file for more info.

rust-to-ios's People

Contributors

wojteklu avatar

Watchers

Chris Ballinger avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.