KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Automating Launch of 4D Built Applications on macOS Using Custom Launch Agents
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac
Published On: September 8, 2025

Custom Launch Agents provide a native macOS mechanism to automate the launch of 4D built applications. By configuring a property list (.plist) file and loading it via launchctl, the application can run automatically based on defined triggers, improving reliability and integration with system events.

Key steps include:

  • Create a .plist file and save it in ~/Library/LaunchAgents/ with a unique label,e.g., com.example.myagent.plist.
  • Define triggers such as RunAtLoad for startup or StartInterval for periodic execution.
  • Ensure proper permissions (e.g., chmod 644 com.example.myagent.plist).

Below is an example of a plist file that ensures the 4D built application launches as a proper GUI application every 300 seconds, without keeping it alive indefinitely.:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.example.myagent</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/open</string>
        <string>-a</string>
        <string>/Applications/4D-Built-Apps/AppName.app</string>
    </array>
    <key>RunAtLoad </key>
    <true/>
    <key>KeepAlive</key>
    <false/>
    <key>StartInterval</key>
    <integer>300</integer>
    <key>StandardOutPath</key>
    <string>/tmp/AppNamelog</string>
    <key>StandardErrorPath</key>
    <string>/tmp/AppName_error.log</string>
</dict>
</plist>


Key Elements in the .plist
  • Label: A unique identifier for the Launch Agent (e.g., com.example.myagent).
  • ProgramArguments: An array specifying the command and its arguments to execute
  • RunAtLoad: If set to <true>, the agent runs immediately after loading (e.g., on user login).
  • KeepAlive: If <true>, the agent restarts automatically if it crashes or exits.
  • StartInterval: Specifies how often (in seconds) the task should

The macOS Terminal command to load (and thereby launch) a user-specific Launch Agent is:

launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/


Replace with the actual name of your .plist file (e.g., com.example.myagent). This registers the agent with launchd in the current user's GUI domain, enabling it to run based on its configured triggers (e.g., StartInterval for scheduled tasks or KeepAlive for reliability). If the agent is already loaded, use launchctl bootout gui/$(id -u) -k <label> to unload it (replace <label> with the Label key value from the .plist)