Creating a new crate
First, if you havenโt done so already, create a new crate within your project directory
using cargo new --lib. It is recommended that the crate root is a sibling of the other native build
folders for ease of config, e.g.:
โโโ android
โโโ ios
โโโ lib
โโโ linux
โโโ macos
โโโ $crate
โย ย โโโ Cargo.toml
โย ย โโโ src
โโโ test
โโโ web
โโโ windows
Throughout this section we will refer to your crate name as $crate. Unless otherwise noted, the crate folder and the crate name will be used interchangeably.
Next, add these two lines to your Cargo.toml:
+[lib]
+crate-type = ["staticlib", "cdylib"]
This configures your crate to be output as a static library for MacOS and iOS,
and a dynamic library on other platforms. Configure this to your needs.
If you would like to write tests or benchmarks, append "rlib" to the list
as well.