Electron Forge
  • Getting Started
  • Importing an Existing Project
  • CLI
  • Core Concepts
    • Why Electron Forge?
    • Build Lifecycle
  • Configuration
    • Configuration Overview
    • TypeScript Setup
    • Plugins
      • Webpack Plugin
      • Vite Plugin
      • Electronegativity Plugin
      • Auto Unpack Native Modules Plugin
      • Local Electron Plugin
      • Fuses Plugin
    • Makers
      • AppX
      • deb
      • DMG
      • Flatpak
      • pkg
      • RPM
      • Snapcraft
      • Squirrel.Windows
      • WiX MSI
      • ZIP
    • Publishers
      • Bitbucket
      • Electron Release Server
      • GitHub
      • Google Cloud Storage
      • Nucleus
      • S3
      • Snapcraft
    • Hooks
  • Built-in Templates
    • Webpack
    • Webpack + Typescript
    • Vite
    • Vite + TypeScript
  • Guides
    • Code Signing
      • Signing a Windows app
      • Signing a macOS app
    • Custom App Icons
    • Framework Integration
      • React
      • React with TypeScript
      • Vue 3
    • Developing with WSL
  • Advanced
    • Auto Update
    • Debugging
    • Extending Electron Forge
      • Writing Plugins
      • Writing Templates
      • Writing Makers
      • Writing Publishers
    • API Docs
Powered by GitBook
On this page
  • Requirements
  • Installation
  • Usage
  • Adding installation scripts
  • Debugging

Was this helpful?

Edit on GitHub
  1. Configuration
  2. Makers

pkg

Create a .pkg file for your Electron app on macOS using Electron Forge.

PreviousFlatpakNextRPM

Last updated 11 days ago

Was this helpful?

The pkg target builds a .pkg installer for macOS. These are used to upload your application to the Mac App Store (MAS), or can be used as an alternate distribution method to users outside of the app store.

This format is often referred to as a flat package installers for historical purposes. Prior to Mac OS X Leopard (10.5), installation packages were organized in hierarchical directories. OS X Leopard introduced a new flat package format that is used for modern .pkg installers.

The flat installer package format is sparsely documented by Apple. If you want to learn more about its specification, there are a few userland articles available:

Requirements

You can only build the pkg target on macOS machines while targeting the darwin or mas platforms.

Installation

npm install --save-dev @electron-forge/maker-pkg

Usage

forge.config.js
module.exports = {
  makers: [
    {
      name: '@electron-forge/maker-pkg',
      config: {
        keychain: 'my-secret-ci-keychain'
        // other configuration options
      }
    }
  ]
};

Adding installation scripts

With the pkg maker, you can add either a preinstall or postinstall bash script that runs before and after your app is installed, respectively.

Both preinstall and postinstall scripts need to:

  • have execution permissions

  • be extension-less

  • be located in the same folder in your filesystem

For example, they can live in a folder in your project called scripts.

my-app
├─── forge.config.js
└─── scripts
    ├── postinstall
    └── preinstall

Then, configure the Maker point its scripts property to the ./scripts folder.

forge.config.js
const path = require('node:path');

module.exports = {
  makers: [
    {
      name: '@electron-forge/maker-pkg',
      config: {
        scripts: path.join(__dirname, 'scripts')
      }
    }
  ]
};

Debugging

For advanced debug logging for this maker, add the DEBUG=electron-osx-sign* environment variable.

(Stéphane Sudre)

(MacTech)

To use @electron-forge/maker-pkg, add it to the makers array in your :

All configuration options are optional, and options are documented in the API docs for .

All logs for your flat package installer can be found in macOS installation logs, which are stored in /var/log/install.log. They are also accessible within the utility.

Flat Package Format - The missing documentation
The Flat Package - Examining a newer package format
Forge configuration
MakerPKGConfig
Console.app
Installation wizard when opening the .pkg installer file