Creating the Rust project
This guide was written for flutter_rust_bridge v1, thus some content may be outdated. The quickest approach to integrate is to follow the one-click approach in flutter_rust_bridge's quickstart page.
First, follow the instructions on the Usage
section of cargo-xcode. The instructions that follow are quoted from there, but keep in mind
that it might have become outdated.
Ensure that these lines are present in your $crate/Cargo.toml:
[lib]
crate-type = ["lib", "staticlib", "cdylib"]
where
libis required for non-library targets, such as tests and benchmarksstaticlibis required for iOScdylibfor all other platforms
Configure this to suit your needs. Then run this command in $crate:
cargo xcode
This will generate a $crate/$crate.xcodeproj that can be imported into other Xcode projects.
You only have to do this once per crate.
Now, open up that $crate/$crate.xcodeproj file with Xcode and select the root item at the left pane. The item's name will be identical to your crate's name. In the Build Settings tab, search for Dynamic Library Install Name Base and change the value into @executable_path/../Frameworks/. This is required by cargo-xcode to enable macOS executable to properly locate .dylib library files in the package.