A Go library for building macOS applications with proper permissions, entitlements, and bundle structure.
macgo simplifies the process of creating macOS applications in Go by automatically handling:
- App bundle creation and management
- Permission requests (camera, microphone, files, etc.)
- Code signing (ad-hoc and Developer ID)
- Entitlements and sandboxing
- TCC (Transparency, Consent, and Control) integration
go get github.com/tmc/macgopackage main
import (
"log"
"github.com/tmc/macgo"
)
func main() {
// Request camera permission with automatic app bundle creation
err := macgo.Request(macgo.Camera)
if err != nil {
log.Fatal(err)
}
// Your application code here
}Request macOS permissions with a single function call:
// Request single permission
macgo.Request(macgo.Camera)
// Request multiple permissions
macgo.Request(macgo.Camera, macgo.Microphone, macgo.Files)macgo automatically creates a proper .app bundle structure with:
- Info.plist with required metadata
- Entitlements for requested permissions
- Proper executable location
- App icons (if provided)
Built-in support for code signing:
// Ad-hoc signing (development)
cfg := macgo.NewConfig().
WithAppName("MyApp").
WithAdHocSign()
// Developer ID signing (distribution)
cfg := macgo.NewConfig().
WithAppName("MyApp").
WithAutoSign() // Auto-detects Developer IDConfigure via environment variables:
MACGO_APP_NAME=MyApp # Application name
MACGO_BUNDLE_ID=com.example # Bundle identifier
MACGO_AD_HOC_SIGN=1 # Enable ad-hoc signing
MACGO_AUTO_SIGN=1 # Auto-detect signing identity
MACGO_DEBUG=1 # Debug output- Camera (
macgo.Camera) - Camera access - Microphone (
macgo.Microphone) - Microphone access - Location (
macgo.Location) - Location services - Files (
macgo.Files) - File system access - Network (
macgo.Network) - Network connections - Sandbox (
macgo.Sandbox) - App sandboxing
cfg := macgo.NewConfig().
WithAppName("MyApp").
WithBundleID("com.example.myapp").
WithPermissions(macgo.Camera, macgo.Microphone).
WithAppGroups("group.com.example.shared").
WithDebug()
err := macgo.Start(cfg)Import auto packages for automatic configuration:
import (
_ "github.com/tmc/macgo/auto/media" // Camera + Microphone
_ "github.com/tmc/macgo/auto/adhoc" // Ad-hoc signing
"github.com/tmc/macgo"
)
func main() {
// Permissions and signing are pre-configured
macgo.Request()
}macgo- Core library and main APIbundle/- App bundle creation and managementcodesign/- Code signing utilitiespermissions/- Permission definitions and validationteamid/- Team ID detection for signingauto/- Auto-configuration packagesexamples/- Example applicationsinternal/- Internal implementation packages
See the examples/ directory for complete examples:
getting-started- Basic usagecamera-mic- Media permissionsdesktop-list- File accesscode-signing- Signing examplessandboxed-file-exec- Sandboxed file access
- Go 1.21 or later
- macOS 11.0 or later
- Xcode Command Line Tools (for code signing)
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
This library leverages macOS native frameworks and tools to provide seamless integration with the operating system's security model.