How i can build graphic application (.app) without console's window for osx using rustc?

I want to build application for OSX written on Rust or C/C++ (using rustc or g++). How I can do it?

Your question in the post looks self answered :slight_smile:

No. I don't know how flags and properties i need to use.

1 Like

rustc and cargo doesn't have any functionality for this (as far as I'm aware at least) I use Tundra for building my projects (which I added Rust support to) and it supports a "OsxBundle" step which runs ibtool and setups the correct directory structure and such. You also need to supply a .plist which the tool will expect.

There is an example for this here (not in Rust) https://github.com/deplinenoise/tundra/tree/master/examples/osx-bundle that perhaps can help you guide the way you can do this.

Hopefully this helps.

2 Likes

Another option is to create an ObjC app in Xcode and link it with a static library produced by Rust.

2 Likes

No special flags are needed.

On OS X, the difference between a CLI program and a graphical one is controlled by packaging and by how the program interacts with the user, not by compiler flags or linkage. Any program can be wrapped up in a .app bundle, and will not spawn a terminal if run that way. Conversely, a desktop program can be run from the CLI by finding the binaries in the bundle and running them like ordinary programs, under most circumstances.

Neither rustc nor cargo have features for building app bundles, but there are supporting tools that can do that with your project’s binaries. Apple’s documentation includes a good overview of how bundles are structured and configured. Personally, I’ve had good luck with cargo-bundle for packaging games and other self-contained programs.

As for how to write it, you’ll have to find Rust bindings for OS X’s window manager and UI libs. I’ve used winit, which is intentionally rather minimal, but there are plenty of options out there.

2 Likes

For app bundles IMHO it's best to use Xcode and pull in Rust code as a library. Because setting this up is fiddly, I've created cargo xcode command that makes nicely-integrated projects automatically:

cargo install cargo-xcode;
cargo xcode

and you'll get $crate.xcodeproj for all your Rust staticlib/cdylib/bin targets.

2 Likes