osacompile - macOS


Overview

osacompile is a macOS command-line tool used to compile AppleScript scripts and create standalone applications or script bundles. It allows you to distribute and use scripts as native macOS applications.

Syntax

osacompile [options] <script_file> [<output_file>]

Options/Flags

  • -o, –output: Specify the output file path. If not provided, the script file’s name will be used with a .app extension.
  • -e, –executable: Create a standalone executable file instead of an application bundle.
  • -l, –link: Link external script libraries or modules.
  • -a, –architecture: Specify the architecture (i386, x86_64) for the compiled script.
  • -v, –verbose: Display verbose output during compilation.
  • -h, –help: Display help information.

Examples

Create an Application Bundle:

osacompile -o MyScript.app myscript.scpt

Create a Standalone Executable:

osacompile -e myscript.scpt

Link External Library:

osacompile -l /path/to/library.scpt myscript.scpt

Compile for a Specific Architecture:

osacompile -a i386 myscript.scpt

Common Issues

  • Missing Libraries: Ensure that any external script libraries used in your script are properly linked with the -l option.
  • Compilation Errors: Carefully review error messages during compilation to identify any syntax or logical errors in your script.
  • Permissions Denied: Make sure you have the necessary permissions to write to the output file path.

Integration

Combine with Script Editor: Use osacompile from within Script Editor by selecting the “Compile” option from the File menu.

Create Custom macOS Applications: Package your scripts as standalone applications to distribute and run them seamlessly on other macOS systems.

  • applescript: Run AppleScript scripts directly from the command line.
  • scpt: Create and edit AppleScript scripts.
  • AppleScript Documentation