swift-bridge icon indicating copy to clipboard operation
swift-bridge copied to clipboard

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

Open sax opened this issue 2 years ago • 1 comments

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.

sax avatar Mar 13 '24 20:03 sax

I was stuck until I found this issue.

Nek avatar Jun 30 '25 14:06 Nek