# Including Rust files inside Swift project

**URL:** <https://forums.swift.org/t/including-rust-files-inside-swift-project/45521>\
**Category:** Using Swift\
**Tags:** packagemanager\
**Created:** [March 10, 2021, 8:47am UTC](https://forums.swift.org/t/including-rust-files-inside-swift-project/45521 "2021-03-10T08:47:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![asdf](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@asdf](https://forums.swift.org/u/asdf)\
**Post date:** [March 10, 2021, 8:47am UTC](https://forums.swift.org/t/including-rust-files-inside-swift-project/45521/1 "2021-03-10T08:47:36Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![lukasa](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lukasa/32/1232_2.png) [@lukasa](https://forums.swift.org/u/lukasa)\
**Post date:** [March 10, 2021, 10:45am UTC](https://forums.swift.org/t/including-rust-files-inside-swift-project/45521/2 "2021-03-10T10:45:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![SDGGiesbrecht](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sdggiesbrecht/32/4768_2.png) [@SDGGiesbrecht](https://forums.swift.org/u/SDGGiesbrecht)\
**Post date:** [March 10, 2021, 11:04pm UTC](https://forums.swift.org/t/including-rust-files-inside-swift-project/45521/3 "2021-03-10T23:04:04Z")

</div>

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

> [@SE-0303: Package Manager Extensible Build Tools](https://forums.swift.org/t/se-0303-package-manager-extensible-build-tools/45106):
>
> The review of [SE-0303](https://github.com/apple/swift-evolution/blob/main/proposals/0303-swiftpm-extensible-build-tools.md), begins now and runs through March 12, 2021. Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to the review manager or direct message in the Swift forums). What goes into a review of a proposal? The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of S…

---

<div class="post-metadata">

**Author:** ![Keith](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/keith/32/291_2.png) [@Keith](https://forums.swift.org/u/Keith)\
**Post date:** [March 10, 2021, 11:06pm UTC](https://forums.swift.org/t/including-rust-files-inside-swift-project/45521/4 "2021-03-10T23:06:05Z")

</div>

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](https://www.bazel.build/) 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)

---

<div class="post-metadata">

**Author:** ![asdf](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@asdf](https://forums.swift.org/u/asdf)\
**Post date:** [March 11, 2021, 5:23am UTC](https://forums.swift.org/t/including-rust-files-inside-swift-project/45521/5 "2021-03-11T05:23:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Keith](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/keith/32/291_2.png) [@Keith](https://forums.swift.org/u/Keith)\
**Post date:** [March 11, 2021, 5:33am UTC](https://forums.swift.org/t/including-rust-files-inside-swift-project/45521/6 "2021-03-11T05:33:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![asdf](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@asdf](https://forums.swift.org/u/asdf)\
**Post date:** [March 11, 2021, 5:40am UTC](https://forums.swift.org/t/including-rust-files-inside-swift-project/45521/7 "2021-03-11T05:40:52Z")

</div>

ok
