chinedufn / swift-bridge

swift-bridge facilitates Rust and Swift interop.
https://chinedufn.github.io/swift-bridge
Apache License 2.0
842 stars 62 forks source link

Book update: Xcode 15 (at least) requires a bridge in order to import into swift #255

Open sax opened 8 months ago

sax commented 8 months ago

I'm going through the swift-bridge book, and ran into an issue. The Xcode + Cargo guide has one create an empty rust library, and then configure the Xcode project to import it. When my src/lib.rs does not have any contents, then when I try to build the project (Pressing the Run button should now open up the iOS simulator with Xcode's default "Hello World" iOS app.), then my Xcode build fails with a ton of errors: Undefined symbol: ___swift_bridge__$RustStr$partial_eq, ...$_free, ...$as_str, etc.

When I add the mod ffi code to the Rust lib, then the Xcode build succeeds, even when nothing in Swift calls into the lib.

Rust: 1.76.0 (07dca489a 2024-02-04) Xcode: Version 15.3 (15E204a)

I think this would be solved by reorganizing the page to add the RustApp to the lib before trying to build in Xcode.