Including Rust files inside Swift project

Is it possible to include rust files in swift project?
Something like:

SwiftProj
    |---Package.swift
    |---Sources
          |---SwiftModule
          |---RustModule
               |---libheader.h
               |---Cargo.toml
               |---src
                    |---lib.rs

Then just invoke swift build

Today it is not possible to do this. In the eventual future it should be possible to run external build tools, but Rust is a complex one to express. I do not believe there is any roadmap to do this today.

2 Likes

If this goes through, I suspect something like what you are asking would become possible:

If you're interested in doing something like this today, and you're willing to put a lot of work into it, you can go down the path of using bazel which supports rust and Swift and they could theoretically intermingle in the same build that way (although I don't know of anyone doing this today for rust specifically)

would it be possible without other build tool?
i mean just invoke swift build and swiftPM will invoke cargo

Nope, as others said rust isn't supported by swiftpm today.

ok