macOS-specific packaging options including DMG creation, code signing, notarization, and App Store distribution. Supports both Intel and Apple Silicon architectures with universal binary creation.
Comprehensive macOS build configuration with code signing and distribution options.
/**
* macOS-specific build configuration
*/
interface MacConfiguration extends PlatformSpecificBuildOptions {
/** Code signing identity */
identity?: string | null;
/** Application icon (.icns file) */
icon?: string | null;
/** Entitlements plist file path */
entitlements?: string | null;
/** Inherited entitlements plist file path */
entitlementsInherit?: string | null;
/** Provisioning profile path (for App Store) */
provisioningProfile?: string | null;
/** Bundle version (CFBundleVersion) */
bundleVersion?: string | null;
/** Bundle short version (CFBundleShortVersionString) */
bundleShortVersion?: string | null;
/** Helper bundle ID */
helperBundleId?: string | null;
/** Renderer helper bundle ID */
helperRendererBundleId?: string | null;
/** Plugin helper bundle ID */
helperPluginBundleId?: string | null;
/** GPU helper bundle ID */
helperGPUBundleId?: string | null;
/** EH helper bundle ID */
helperEHBundleId?: string | null;
/** Distribution type */
type?: "distribution" | "development" | null;
/** Extended Info.plist properties */
extendInfo?: any;
/** Additional binaries to sign */
binaries?: Array<string> | null;
/** Minimum macOS version */
minimumSystemVersion?: string | null;
/** Code signing requirements */
requirements?: string | null;
/** Electron supported languages */
electronLanguages?: Array<string> | string;
/** Strict verify for signing */
strictVerify?: boolean | string | Array<string>;
/** Gatekeeper assessment */
gatekeeperAssess?: boolean;
/** Dark mode support */
darkModeSupport?: boolean;
/** Merge ASARs for universal build */
mergeASARs?: boolean;
/** x64 architecture files pattern */
x64ArchFiles?: string;
/** Single architecture files pattern */
singleArchFiles?: string;
/** Application category */
category?: string | null;
}Usage Examples:
import { MacConfiguration } from "electron-builder";
const macConfig: MacConfiguration = {
identity: "Developer ID Application: My Company (TEAM123456)",
icon: "build/icon.icns",
category: "public.app-category.productivity",
minimumSystemVersion: "10.15.0",
darkModeSupport: true,
entitlements: "build/entitlements.plist",
entitlementsInherit: "build/entitlements.inherit.plist",
gatekeeperAssess: false,
extendInfo: {
NSCameraUsageDescription: "This app needs camera access",
NSMicrophoneUsageDescription: "This app needs microphone access"
}
};Configuration for DMG disk image creation with visual customization.
/**
* DMG disk image creation options
*/
interface DmgOptions {
/** Background image for DMG window */
background?: string | null;
/** Background color (if no image) */
backgroundColor?: string | null;
/** DMG volume icon */
icon?: string | null;
/** Icon size in pixels */
iconSize?: number | null;
/** Icon text size */
iconTextSize?: number | null;
/** DMG volume title */
title?: string | null;
/** DMG window contents layout */
contents?: Array<DmgContent>;
/** DMG compression format */
format?: "UDZO" | "UDBZ" | "ULFO" | "UDRO" | "UDCO" | "UDRW" | "UDTO" | "UDSP" | "UDSB" | "UFBI";
/** DMG window configuration */
window?: DmgWindow | null;
/** Enable internet features */
internetEnabled?: boolean;
/** Sign the DMG */
sign?: boolean;
/** Write update info to DMG */
writeUpdateInfo?: boolean;
}
/**
* DMG contents positioning
*/
interface DmgContent {
/** Item x coordinate */
x: number;
/** Item y coordinate */
y: number;
/** Item type */
type?: "link" | "file" | "dir";
/** Item name */
name?: string;
/** Item path (for links) */
path?: string;
}
/**
* DMG window appearance
*/
interface DmgWindow {
/** Window x position */
x?: number;
/** Window y position */
y?: number;
/** Window width */
width: number;
/** Window height */
height: number;
}Usage Examples:
import { DmgOptions, DmgContent } from "electron-builder";
const dmgOptions: DmgOptions = {
background: "build/dmg-background.png",
iconSize: 80,
window: {
width: 600,
height: 400
},
contents: [
{ x: 150, y: 200, type: "file" },
{ x: 450, y: 200, type: "link", path: "/Applications" }
],
format: "UDZO",
sign: true
};
const config = {
mac: {
target: [
{ target: "dmg", arch: ["x64", "arm64"] }
]
},
dmg: dmgOptions
};Configuration for macOS PKG installer creation.
/**
* macOS PKG installer options
*/
interface PkgOptions {
/** Custom scripts directory */
scripts?: string | null;
/** Installation location */
installLocation?: string | null;
/** Allow current user home installation */
allowCurrentUserHome?: boolean;
/** Allow anywhere on disk installation */
allowAnywhere?: boolean;
/** Allow root user installation */
allowRootDirectory?: boolean;
/** Package identity for signing */
identity?: string | null;
/** Installation background */
background?: PkgBackgroundOptions | string | null;
/** Welcome text */
welcome?: string | null;
/** License text */
license?: string | null;
/** Conclusion text */
conclusion?: string | null;
/** Installer must close apps */
mustClose?: Array<string> | null;
/** Is relocatable package */
isRelocatable?: boolean;
/** Override file permissions */
overwriteAction?: "upgrade" | "update" | null;
}
/**
* PKG background options
*/
interface PkgBackgroundOptions {
/** Background image file */
file: string;
/** Background alignment */
alignment?: BackgroundAlignment;
/** Background scaling */
scaling?: BackgroundScaling;
}
type BackgroundAlignment = "center" | "left" | "right" | "top" | "bottom" | "topleft" | "topright" | "bottomleft" | "bottomright";
type BackgroundScaling = "tofit" | "none" | "proportionally";Mac App Store specific configuration and distribution options.
/**
* Mac App Store configuration
*/
interface MasConfiguration extends MacConfiguration {
/** MAS category */
category?: string | null;
/** MAS application bundle ID */
bundleId?: string | null;
/** Signing identity for distribution */
identity?: string | null;
/** Installer identity */
installerIdentity?: string | null;
/** MAS entitlements */
entitlements?: string | null;
/** MAS inherited entitlements */
entitlementsInherit?: string | null;
/** Provisioning profile */
provisioningProfile?: string | null;
/** Binaries to sign */
binaries?: Array<string> | null;
}
/**
* Available macOS target names
*/
type MacOsTargetName = "default" | "dmg" | "mas" | "mas-dev" | "pkg" | "tar.gz" | "tar.lz" | "tar.bz2" | "zip";Usage Examples:
import { MasConfiguration } from "electron-builder";
const masConfig: MasConfiguration = {
identity: "3rd Party Mac Developer Application: My Company (TEAM123456)",
installerIdentity: "3rd Party Mac Developer Installer: My Company (TEAM123456)",
provisioningProfile: "build/embedded.provisionprofile",
category: "public.app-category.productivity",
entitlements: "build/entitlements.mas.plist",
entitlementsInherit: "build/entitlements.mas.inherit.plist"
};
const config = {
mac: masConfig,
mas: {
// MAS-specific overrides
type: "distribution"
}
};macOS code signing configuration with custom signing functions.
/**
* Custom macOS signing function
*/
interface CustomMacSign {
(configuration: CustomMacSignOptions, packager: MacPackager): Promise<any>;
}
/**
* Custom signing configuration
*/
interface CustomMacSignOptions {
/** Application path to sign */
appPath: string;
/** Platform packager */
packager: MacPackager;
/** Identity to use for signing */
identity: string | null;
/** Entitlements file */
entitlements?: string | null;
/** Options for signing */
options: any;
}
/**
* macOS packager with signing capabilities
*/
class MacPackager extends PlatformPackager {
/** Sign application with identity */
sign(appPath: string, options?: any): Promise<void>;
/** Create app bundle */
createAppBundle(appOutDir: string, arch: Arch): Promise<void>;
/** Package application */
pack(outDir: string, arch: Arch, targets: Array<Target>): Promise<any>;
}Usage Examples:
import { MacConfiguration, CustomMacSign } from "electron-builder";
// Custom signing function
const customSign: CustomMacSign = async (configuration, packager) => {
console.log(`Signing ${configuration.appPath}`);
// Custom signing logic
await packager.sign(configuration.appPath, {
identity: configuration.identity,
entitlements: configuration.entitlements
});
};
const config: MacConfiguration = {
// Use custom signing
sign: customSign,
identity: "Developer ID Application: My Company",
entitlements: "build/entitlements.plist"
};Apple notarization support for distribution outside the App Store.
/**
* Notarization options (configured via environment variables)
*/
interface NotarizationOptions {
/** Apple ID username */
appleId?: string;
/** Apple ID password or app-specific password */
appleIdPassword?: string;
/** Apple team ID */
appleTeamId?: string;
}Environment variables for notarization:
APPLE_ID - Apple ID usernameAPPLE_ID_PASSWORD - Apple ID password or app-specific passwordAPPLE_TEAM_ID - Apple Team IDUsage Examples:
// Notarization is enabled automatically when:
// 1. Building for distribution (not development)
// 2. Code signing identity is set
// 3. Required environment variables are present
const config = {
mac: {
identity: "Developer ID Application: My Company (TEAM123456)",
// Notarization will be attempted automatically
gatekeeperAssess: false // Skip Gatekeeper assessment during build
}
};
// Environment setup for CI/CD
process.env.APPLE_ID = "developer@company.com";
process.env.APPLE_ID_PASSWORD = "app-specific-password";
process.env.APPLE_TEAM_ID = "TEAM123456";Configuration for creating universal binaries supporting both Intel and Apple Silicon.
// Universal binary target configuration
const universalConfig = {
mac: {
target: [
{
target: "dmg",
arch: ["universal"] // Creates universal binary
},
{
target: "dmg",
arch: ["x64", "arm64"] // Creates separate binaries
}
],
mergeASARs: true, // Merge ASAR files for universal build
x64ArchFiles: "*.{dylib,node}", // Files specific to x64
singleArchFiles: "native/**/*" // Files not to merge
}
};macOS packaging provides comprehensive support for modern macOS distribution requirements including code signing, notarization, universal binaries, and both direct distribution and App Store submission workflows.