darwin

package
v0.14.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package darwin handles macOS-specific build steps — wrapping the raw binary into a .app bundle and (host-darwin only) further wrapping that into a .dmg disk image. Pure-Go .app construction works from any host; .dmg requires the macOS-only `hdiutil` tool.

Index

Constants

This section is empty.

Variables

View Source
var ErrSkippedDMG = errors.New("dmg: hdiutil unavailable on non-darwin host")

ErrSkippedDMG is returned when DMG creation is skipped because the host OS is not darwin (hdiutil is macOS-only). Callers may treat this as a non-fatal warning.

View Source
var ErrSkippedSign = errors.New("codesign: skipped on non-darwin host")

ErrSkippedSign is returned when ad-hoc codesign is skipped because the host OS is not darwin (codesign is macOS-only). Callers may treat this as a non-fatal warning — the resulting .app is still usable for developers building locally, just unsigned.

Functions

func PackageApp

func PackageApp(binPath, gateBinPath, appName, appVersion, bundleID string) (string, error)

PackageApp wraps a built darwin binary into a standard .app bundle:

bin/<app>.app/
├── Contents/
│   ├── Info.plist
│   ├── MacOS/<app>          (the main binary, copied)
│   ├── MacOS/<app>-gate     (gate sidecar, when shipped)
│   └── Resources/icon.icns  (rendered from the brand W)

gateBinPath (optional) is the gate sidecar to ship as `Contents/MacOS/<AppName>-gate`. Empty = no sidecar (the main binary still has gate embedded; runtime extracts to the session dir on first hook fire). When non-empty, sibling lookup picks up the bundled gate before any extract.

Returns the bundle root path. Source binaries are COPIED (not moved) so the raw artifacts remain available for the self-updater and for naming-consistent CI uploads.

func PackageDMG

func PackageDMG(appPath, dmgPath, volName string, installerLayout bool) (string, error)

PackageDMG wraps an existing .app bundle into a UDZO-compressed .dmg disk image via the macOS `hdiutil` tool.

When installerLayout is true, the image is staged so it also contains an "Applications" symlink — Finder then shows the standard "drag-to-install" layout when the user mounts it. When false, the .dmg embeds just the .app (current/legacy behavior).

Returns the .dmg path on success; returns ErrSkippedDMG when the host is not darwin (the .app bundle alone is still useful then).

volName is the visible name when the user mounts the disk image; dmgPath is the output filename (typically <app>-darwin-<arch>.dmg).

func SignAdHoc added in v0.13.0

func SignAdHoc(appPath string) error

SignAdHoc applies an ad-hoc signature to a .app bundle. Without this, an unsigned binary plus the com.apple.quarantine xattr that macOS attaches to anything downloaded over the network produces a hard "<app> is damaged and can't be opened" dialog on Apple Silicon — and unlike the milder "unidentified developer" warning, that one has no right-click → Open override path.

Ad-hoc signing (codesign -s -) is not Developer ID and does NOT substitute for notarization. Users still see the unidentified-dev warning on first launch, but they can bypass it via right-click → Open or System Settings → Privacy & Security → Open Anyway. No terminal required.

--deep walks nested executables inside the bundle (Contents/MacOS/ <App>, <App>-gate) so the gate sidecar is signed too. --force overwrites any prior signature so reruns in CI are idempotent.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL