Skip to main content
Installing macOS kernel extensions with electron-builder can be done using scripts that run during the installation process.

Configuration

First, configure your app to build a package (.pkg) instead of the default .dmg:
package.json

Script Setup

Place your script and the kernel extensions in build/pkg-scripts, or define a custom directory.

Requirements

The script must be called either preinstall or postinstall
Use #!/bin/sh as the first line in your script
The script must be executable (chmod +x <filename>)

Example Script

Here’s an example postinstall script for managing kernel extensions:
build/pkg-scripts/postinstall

Making the Script Executable

Before building, ensure your script has execute permissions:

Workflow

  1. Unload existing extensions - Use kextunload to unload any old versions
  2. Remove old files - Delete old extension files from /Library/Extensions/
  3. Copy new extensions - Copy your new .kext files to the system directory
  4. Load new extensions - Use kextload to activate the new extensions

Directory Structure

Custom Script Directory

To use a custom directory for your scripts, configure the scripts option: