bundle

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package bundle provides macOS app bundle creation and management functionality. This package handles the creation, configuration, and signing of macOS app bundles for Go applications that need to access protected system resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSignatureInfo

func GetSignatureInfo(bundlePath string) (map[string]string, error)

GetSignatureInfo retrieves detailed information about the bundle's code signature. Returns the signing identity, team ID, and other signature details.

func VerifySignature

func VerifySignature(bundlePath string) error

VerifySignature verifies that a bundle is properly code signed. Returns nil if the signature is valid, error otherwise.

Types

type Bundle

type Bundle struct {
	// Path is the full path to the .app bundle directory
	Path string

	// Config contains the bundle configuration
	Config *Config
	// contains filtered or unexported fields
}

Bundle represents a macOS app bundle with its configuration and management methods.

func Create

func Create(execPath string, appName, bundleID, version string, permissions []string,
	custom []string, customStrings map[string]string, customArrays map[string][]string, appGroups []string, debug bool, cleanupBundle bool,
	codeSignIdentity, codeSigningIdentifier string, autoSign, adHocSign bool,
	info map[string]interface{}, uiMode UIMode, devMode bool, provisioningProfile string, iconPath string) (*Bundle, error)

Create is a convenience function that creates a bundle from execPath and config fields. This avoids the need for complex config conversion.

func New

func New(execPath string, config *Config) (*Bundle, error)

New creates a new Bundle instance for the given executable and configuration.

func (*Bundle) BundleID

func (b *Bundle) BundleID() string

BundleID returns the bundle identifier.

func (*Bundle) CleanName

func (b *Bundle) CleanName() string

CleanName returns the cleaned application name.

func (*Bundle) Create

func (b *Bundle) Create() error

Create creates the app bundle with the configured settings. This method implements the functionality from createSimpleBundle.

func (*Bundle) ExecutablePath

func (b *Bundle) ExecutablePath() string

ExecutablePath returns the path to the executable inside the bundle.

func (*Bundle) ForceResign

func (b *Bundle) ForceResign()

ForceResign clears the reused flag so the next Sign() call performs code signing even if Create() determined the bundle was up-to-date. Use this after modifying bundle contents via a post-create hook.

func (*Bundle) Sign

func (b *Bundle) Sign() error

Sign performs code signing on the bundle. This method coordinates the signing process and delegates to signing.go. If the bundle was reused (not recreated), signing is skipped since the existing signature is still valid.

func (*Bundle) Validate

func (b *Bundle) Validate() error

Validate checks if the bundle is properly formed and signed.

func (*Bundle) Version

func (b *Bundle) Version() string

Version returns the application version.

type Config

type Config struct {
	// AppName is the application name. Defaults to executable name.
	AppName string

	// BundleID is the bundle identifier. Defaults to inferred from module path or environment.
	BundleID string

	// Version is the application version. Defaults to "1.0.0".
	Version string

	// Permissions are the requested macOS permissions.
	Permissions []string

	// Custom allows specifying custom entitlements not covered by Permission constants.
	Custom []string

	// CustomStrings allows specifying custom entitlements with string values.
	CustomStrings map[string]string

	// CustomArrays allows specifying custom entitlements with array values.
	CustomArrays map[string][]string

	// AppGroups specifies app group identifiers for sharing data between apps.
	AppGroups []string

	// Debug enables debug logging.
	Debug bool

	// CleanupBundle enables cleanup of the app bundle after execution.
	CleanupBundle bool

	// CodeSignIdentity is the signing identity to use for code signing.
	CodeSignIdentity string

	// AutoSign enables automatic detection of Developer ID certificates.
	AutoSign bool

	// AdHocSign enables ad-hoc code signing using the "-" identity.
	AdHocSign bool

	// CodeSigningIdentifier is the identifier to use for code signing.
	CodeSigningIdentifier string

	// Info allows specifying custom Info.plist keys.
	Info map[string]interface{}

	// UIMode controls how the app appears in the UI.
	// Default (empty or UIModeBackground): LSBackgroundOnly=true for CLI tools.
	UIMode UIMode

	// DevMode creates a stable wrapper bundle that exec's the original binary.
	// This preserves TCC permissions across rebuilds since only the wrapper is signed,
	// not the development binary. Enable via MACGO_DEV_MODE=1 for development workflows.
	DevMode bool

	// ProvisioningProfile is the path to a provisioning profile to embed in the bundle.
	ProvisioningProfile string

	// IconPath is the path to an .icns file to use as the app icon.
	IconPath string

	// ResolvedSigningIdentity is set during Sign() to the identity actually used.
	// PostCreateHook users can read this to sign inner binaries with the same identity.
	ResolvedSigningIdentity string
}

Config holds configuration options for bundle creation and signing. This is a subset of the main macgo Config, containing only bundle-specific fields.

type ProfileEntitlements

type ProfileEntitlements struct {
	ApplicationIdentifier string
	TeamIdentifier        string
}

ProfileEntitlements holds entitlement values extracted from a provisioning profile.

type UIMode

type UIMode string

UIMode controls how the app appears in the macOS UI.

const (
	// UIModeBackground sets LSBackgroundOnly=true. No UI at all.
	// Use for CLI tools, MCP servers, daemons. Prevents -1712 timeout.
	UIModeBackground UIMode = "background"

	// UIModeAccessory sets LSUIElement=true. Can show windows/menu bar but no Dock icon.
	// Use for menu bar apps, floating utilities.
	UIModeAccessory UIMode = "accessory"

	// UIModeRegular is a normal app with Dock icon and full UI.
	// Use for standard GUI applications.
	UIModeRegular UIMode = "regular"
)

Jump to

Keyboard shortcuts

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