Swift -> Rust -> Swift Package

Hi everyone,
I am new to rust language and seeking help with one problem I am facing with FFI and a complex linking scenario.

I have a huge rust project (A) and a specific module (B) in my rust project needed a swift library (C). I achieved it by developing a static library of swift package (C) and linking it with the rust module (B) in my rust project (A). Now, when I test my rust code, everything works as expected.

High-level overview: C ---(statically linked)---> B ---(rust import)---> A

Now, when I try to compile A as a swift package (D), I am able to compile D successfully but when I try to build swift tests by importing D, I am receiving symbols not found error.

ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: fatalError
[6/9] Linking libRust.dylib
error: fatalError
make: *** [swift-test] Error 1

The swift package is being generated automatically using cargo-swift crate. I am thinking the possible problem might be because of not linking the static swift package (C) while compiling (D), but I might be wrong as well.

I am reaching out to this community to seek some guidance on how I can achieve the linking and get this end to end working.

C --> B --> A --> D

I got the B --> A --> D flow working without issues but receiving linker issues when trying the C --> B --> A --> D flow.

Thank you for your time and attention on this topic!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.