Crate fruitbasket[][src]

Expand description

fruitbasket - Framework for running Rust programs in a Mac ‘app bundle’ environment.

fruitbasket provides two different (but related) services for helping you run your Rust binaries as native AppKit/Cocoa applications on Mac OS X:

  • App lifecycle and environment API - fruitbasket provides an API to initialize the AppKit application environment (NSApplication), to pump the main application loop and dispatch Apple events in a non-blocking way, to terminate the application, to access resources in the app bundle, and various other tasks frequently needed by Mac applications.

  • Self-bundling app ‘trampoline’ - fruitbasket provides a ‘trampoline’ to automatically bundle a standalone binary as a Mac application in a .app bundle at runtime. This allows access to features that require running from a bundle ( such as XPC services), self-installing into the Applications folder, registering your app with the system as a document type or URL handler, and various other features that are only available to bundled apps with unique identifiers. Self-bundling and relaunching itself (the “trampoline” behavior) allows your app to get the features of app bundles, but still be launched in the standard Rust ways (such as cargo run).

The primary goal of fruitbasket is to make it reasonably easy to develop native Mac GUI applications with the standard Apple AppKit/Cocoa/Foundation frameworks in pure Rust by pushing all of the Apple and Objective-C runtime logic into dedicated libraries, isolating the logic of a Rust binary application from the unsafe platform code. As the ecosystem of Mac libraries for Rust grows, you should be able to mix-and-match the libraries your application needs, pump the event loop with fruitbasket, and never worry about Objective-C in your application.

Getting Started

You likely want to create either a Trampoline or a FruitApp right after your Rust application starts. If uncertain, use a Trampoline. You can hit very strange behavior when running Cocoa apps outside of an app bundle.

Structs

Main interface for controlling and interacting with the AppKit app

An opaque, thread-safe object that can interrupt the run loop.

API to move the executable into a Mac app bundle and relaunch (if necessary)

Enums

Policies controlling how a Mac application’s UI is interacted with

Docs in OS X build.

Class for errors generated by fruitbasket. Dereferences to a String.

Options for where to save generated app bundle

Options for where to save logging output generated by fruitbasket

Options for how long to run the event loop on each call

Constants

Info.plist entries that have default values, but can be overridden

Info.plist entries that are set, and cannot be overridden

Apple kAEGetURL constant

Apple kInternetEventClass constant

Apple keyDirectObject constant

Functions

Enable logging to rolling log files with Rust log library

Docs in OS X build.

Docs in OS X build.

Type Definitions

Docs in OS X build.