ferrokit-build
Compiles a Mac app's Swift code from build.rs and links it into the app, so Rust can call Swift, including SwiftUI views, through @_cdecl functions. Part of Ferrokit, the native macOS GUI framework for Rust.
[]
= "0.15"
// build.rs
- Sources: every
.swiftfile underswift/(subfolders too) becomes one Swift module, named after the package (my-appbecomesMyApp). - Links what it needs: the Swift runtime and the frameworks your Swift imports (SwiftUI, Charts…) are linked automatically. They come with macOS, so nothing is copied into the app.
- Follows the build: the target architecture (Apple silicon, Intel and universal builds), the Cargo profile's optimisation and debug info, and
MACOSX_DEPLOYMENT_TARGET(15.0 by default). - Options:
.module(..),.min_macos(..),.swift_version("6"),.flag(..);try_compile()returns the error instead of stopping the build. - Errors:
swiftc's own errors show in the build output. - Toolchain:
swiftccomes with the Command Line Tools (xcode-select --install). SwiftUI's macros (@State,@Entry,#Preview, macros since the macOS 27 SDK) need Xcode, which has their plugin: when an Xcode is in/Applications, it's used for them, with a warning. SettingDEVELOPER_DIRpicks a toolchain yourself and turns that fallback off. No Xcode project is needed.
To show a SwiftUI view in a Ferrokit window, return an NSHostingView from Swift and wrap it with ferrokit::native. Ferrokit's guide, chapter 14, has the recipe. A bridge that needs less glue is being designed in issue #7.
macOS only. License: MIT OR Apache-2.0.