Documentation
¶
Overview ¶
Package appbundle is the .app directory a macOS program lives in: whether the running process is inside one, and how to assemble one around an executable.
A bare executable is not an application on this system. AppKit reads what a program is from the bundle around it, so a program that wants a menu-bar item, a dock tile, a name in the menu bar, notification permission or a place in Login Items has to be in one. Asked for from outside a bundle, a status item is asked for by nobody: it never appears, and the process ends without complaining.
Everything here is path and file work — no AppKit, no cgo — so it builds and is tested on every platform, which is what makes a bundle assembler useful in a cross-compiling build.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bundle ¶
type Bundle struct {
// Path is the .app directory itself.
Path string
// Name is what it is called, without the .app.
Name string
}
Bundle is a .app directory.
func Build ¶
Build assembles the bundle and reports where it put it.
It replaces whatever was there: a bundle assembled over the top of an older one keeps files nothing refers to any more, and those are the ones that go stale without anybody noticing.
type Spec ¶
type Spec struct {
// Dir is where the .app is written.
Dir string
// Name is the application's name, and the .app directory's.
Name string
// Identifier is the bundle identifier, in reverse-DNS form.
Identifier string
// Version is what the application reports as its version.
Version string
// Executable is the built program to put inside. It is copied, so the
// caller keeps whatever it built.
Executable string
// Accessory asks for LSUIElement: a program with a menu-bar item and no
// dock tile and no menu of its own, which is what a status-item
// application is.
Accessory bool
// MinimumSystem is the oldest macOS this claims to run on. Empty leaves
// the key out rather than inventing a floor.
MinimumSystem string
// UsageDescriptions are the NS...UsageDescription strings this program
// needs, keyed by the plist key -- "NSCameraUsageDescription" and the like.
//
// ⛔ WITHOUT THE RIGHT ONE, macOS DOES NOT DENY THE PROGRAM, IT ENDS IT.
// Touching a camera, a microphone, the Photos library or a dozen other
// things from a program with no usage description for it is not a refusal a
// caller can handle: TCC terminates the process with "This app has crashed
// because it attempted to access privacy-sensitive data without a usage
// description". A bare binary has no Info.plist at all, which is why a
// program that needs any of these has to be a bundle.
//
// The value is shown to the person in the prompt, so it is a SENTENCE about
// what this program wants it for -- "XR desk shows what the glasses see" --
// and not the name of an API.
UsageDescriptions map[string]string
// Icon is a .icns file's bytes. Empty leaves the bundle without one,
// which is an application drawn as a blank page everywhere it appears.
//
// It is bytes rather than a path because assembling a bundle is the last
// step of a build, and by then the icon is as likely to be embedded in
// the builder as sitting on disk beside it.
Icon []byte
}
Spec is what to assemble.