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?
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.
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?
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/
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
Well, i have same issue. I have a few thoughts what can be wrong.
Check if you need to connect any additional macOS libraries. And put it in Cargo.toml (osx_frameworks)
otool -L target/release/<your_executable>
is useful for checking if the executable will work on other people’s computers. When it links
/usr/lib/* only it’s OK. If it picked some libraries from Homebrew or such, that’s trouble.
Actually really nice tool, didn’t know before. Many thanks.
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1561.60.100)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1454.90.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1454.90.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
Everything from standard libraries.
I’m getting that kind of errors on others machines. Do you have any ideas how to add this libraries? I used
Cargo bundle —release
Before you build, export:
to tell the compiler to support older versions of macOS.
You are really experienced. Could you write me in telegram please? @lalabuy
Please note that you need to run
cargo clean after change in environmental variables, since Cargo doesn’t understand them.
One more thing that you can do for macOS is to disable jemalloc and use system allocator. That might help linking with other libraries and will reduce executable size.