I'm trying to follow the instructions in the book for XCode + Cargo, and I was pulling my hair out getting undefined symbols at the linker stage at the first simulator run. Turns out you just have to add a bit of swift-bridge code to lib.rs in order for the symbols to be generated.
#[swift_bridge::bridge]
mod ffi {
extern "Rust" {
fn add(left: u64, right: u64) -> u64;
}
}
It would be really helpful for newbies to add this to the book, or at least leave it as an issue here for people to find :)
I'm trying to follow the instructions in the book for XCode + Cargo, and I was pulling my hair out getting undefined symbols at the linker stage at the first simulator run. Turns out you just have to add a bit of swift-bridge code to
lib.rsin order for the symbols to be generated.It would be really helpful for newbies to add this to the book, or at least leave it as an issue here for people to find :)