#cargo #iOS

app cargo-lipo

cargo lipo subcommand to automatically create universal libraries for iOS

11 releases (7 stable)

✓ Uses Rust 2018 edition

3.0.1 Jan 2, 2019
2.0.0 Nov 19, 2018
2.0.0-beta-3 Jun 18, 2018
2.0.0-beta-1 Jan 17, 2018
0.1.0 Sep 21, 2015

#6 in Cargo plugins

Download history 199/week @ 2019-01-20 100/week @ 2019-01-27 90/week @ 2019-02-03 199/week @ 2019-02-10 252/week @ 2019-02-17 259/week @ 2019-02-24 275/week @ 2019-03-03 208/week @ 2019-03-10 197/week @ 2019-03-17 309/week @ 2019-03-24 189/week @ 2019-03-31 166/week @ 2019-04-07 177/week @ 2019-04-14 203/week @ 2019-04-21 223/week @ 2019-04-28

837 downloads per month

MIT/Apache

27KB
542 lines

cargo lipo Build Status Crates.io

Provides a cargo lipo subcommand which automatically creates a universal library for use with your iOS application.

Usage

From anywhere you would usually run cargo you can now run cargo lipo or cargo lipo --release to create a universal library for ios, which can be found in $target/universal/{release|debug}/$lib_name.a.

Make sure you have a library target in your Cargo.toml with a crate type of staticlib:

[lib]
name = "..."
crate-type = ["staticlib"]

XCode Integration

cargo-lipo easily integrates with XCode. Although note that his functionality has only been added recently and may not yet be perfect (the XCode build process is somewhat of a blackbox to me).

  1. In your "Build Settings" change "Enable Bitcode" to No.

  2. Add a new "Run Script" phase to your "Build Phases". Place it before "Compile Sources". Add something like the following to the script:

    # The $PATH used by XCode likely won't contain Cargo, fix that.
    # This assumes a default `rustup` setup.
    export PATH="$HOME/.cargo/bin:$PATH"
    
    # --xcode-integ determines --release and --targets from XCode's env vars.
    # Depending your setup, specify the rustup toolchain explicitly.
    cargo-lipo --xcode-integ --manifest-path ../something/Cargo.toml
    
  3. Build the project once, then update the "Link Binary with Libraries" phase: Click the +, then choose "Add Other...". Navigate to your-cargo-project/target/universal/{debug-or-release} and select your library(s).

  4. Go back to your "Build Settings" and add "Library Search Paths" for "Debug" and "Release", pointing to your-cargo-project/target/universal/{debug-or-release}.

Installation

Install cargo lipo with cargo install cargo-lipo. cargo lipo should always be buildable with the latest stable Rust version. For the minimum supported version check .travis.yml.

You also need a rust compiler which can compile for the iOS targets. If you use rustup all you should have to do is

# 64 bit targets (real device & simulator):
rustup target add aarch64-apple-ios x86_64-apple-ios
# 32 bit targets (you probably don't need these):
rustup target add armv7-apple-ios i386-apple-ios

Troubleshooting

Cargo fails with error: can't find crate for `std` : Your rust compiler most likely does not support cross-compiling to iOS.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~6MB
~104K SLoC