cargo lipo
Provides a cargo lipo
subcommand which automatically creates a universal library for use with your iOS application.
Please consider this project deprecated / passively maintained. This is partly because I am not currently working on any iOS projects, and partly because I believe that there exists a better alternative to using lipo
:
One can use architecture (and OS) specific environment variables in Xcode. The OS specific part could be configured in the Xcode project editor last time I tried, but the architecture specific part needed to be added by manually editing the project.pbxproj
file, for example like this:
plain
"LIBRARY_SEARCH_PATHS[sdk=iphoneos*]" = ../path/to/target/debug/<...>;
"LIBRARY_SEARCH_PATHS[sdk=macosx11.1][arch=arm64]" = ../path/to/target/<...>;
"LIBRARY_SEARCH_PATHS[sdk=macosx11.1][arch=x86_64]" = ../path/to/target/<...>;
Thus, I believe that a future iOS support crate should offer primarily two features:
--xcode-integ
flag.project.pbxproj
editing.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
:
toml
[lib]
name = "..."
crate-type = ["staticlib"]
cargo-lipo
easily integrates with Xcode. Although note that this functionality has only been added recently and may not yet be perfect (the Xcode build process is somewhat of a blackbox to me).
In your "Build Settings" change "Enable Bitcode" to No
.
Add a new "Run Script" phase to your "Build Phases". Place it before "Compile Sources". Add something like the following to the script:
```bash
rustup
setup.export PATH="$HOME/.cargo/bin:$PATH"
cargo lipo --xcode-integ --manifest-path ../something/Cargo.toml ```
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).
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}
.
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
```sh
rustup target add aarch64-apple-ios x86_64-apple-ios
rustup target add armv7-apple-ios i386-apple-ios ```
Cargo fails with error: can't find crate for `std`
: Your rust compiler most likely does not support cross-compiling to iOS.
Licensed under either of
at your option.
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.