Bundle Rust executable in MacOS .app or Windows .exe (with assets folder)


#1

Hi everyone!
So I’m trying to use cargo bundle to create a double-clickable, stand-alone bundled application for Mac OS X and Windows, which cargo bundle purports to do. When I run it (cargo bundle --release), it does successfully create a .app, but when I try to run it, it crashes. A quick investigation of the logs in Console.app suggest that this is because it cannot find the assets, but in the Info.plist the location of the assets folder is all correct. Does anyone have suggestions as to how to distribute Rust standalone applications, or fix cargo bundle?

Thanks!!


#2

I use Xcode (and cargo-xcode) to build Mac executables with Rust code supplied as a static library. This way I get all the Mac-specific bundling for free, done Apple’s way.


#3

I don’t need Mac specific bindings, so would that work for just a plain executable? Also, would that require significant changes to my build process?


#4

The extra work is required only for .app bundles (Cocoa GUI, basically). If you want just a plain command-line executable, then you don’t need any of this.

cargo-xcode does require complete change of the build system - replaces it with Xcode.app/xcodebuild.


#5

I am using SDL for this project, so it does have an interface. I just want to distribute it as something that non-programmers can launch and run like a regular application, which on the Mac is a .app.