Module Oui.Macos_app_bundleSource

Sourcetype t = {
  1. app_bundle_dir : OpamFilename.Dir.t;
    (*

    MyApp.app

    *)
  2. contents : OpamFilename.Dir.t;
    (*

    MyApp.app/Contents

    *)
  3. macos : OpamFilename.Dir.t;
    (*

    MyApp.app/Contents/MacOS - executables go here

    *)
  4. frameworks : OpamFilename.Dir.t;
    (*

    MyApp.app/Contents/Frameworks - dylibs go here

    *)
  5. resources : OpamFilename.Dir.t;
    (*

    MyApp.app/Contents/Resources - everything else

    *)
  6. app_name : string;
    (*

    Capitalized app name

    *)
  7. binary_name : string;
    (*

    Main binary name

    *)
  8. bundle_id : string;
    (*

    Bundle identifier

    *)
}

Type representing a macOS .app bundle structure with all its directories

Sourceval create : installer_config:Installer_config.internal -> work_dir:OpamFilename.Dir.t -> t

create ~installer_config ~work_dir creates the .app bundle directory structure and returns a bundle t.

Creates the following directory structure:

  • work_dir/AppName.app/Contents/MacOS/
  • work_dir/AppName.app/Contents/Frameworks/
  • work_dir/AppName.app/Contents/Resources/
Sourceval add_subdir : t -> relative_path:string -> OpamFilename.Dir.t

add_subdir bundle ~relative_path creates a subdirectory under Resources. Example: add_subdir bundle ~relative_path:"lib/myapp" creates Resources/lib/myapp/

File Operations

Sourceval copy_bundle_contents : t -> bundle_dir:OpamFilename.Dir.t -> unit

copy_bundle_contents bundle ~bundle_dir copies all contents from bundle_dir to the Resources directory.

Sourceval install_binary : t -> binary_path:OpamFilename.t -> OpamFilename.t

install_binary bundle ~binary_path copies the binary to the MacOS directory and makes it executable (chmod 755). The binary is copied as bundle.binary_name.

Sourceval copy_dylib : t -> dylib:OpamFilename.t -> OpamFilename.t

copy_dylib bundle ~dylib copies a dylib to the Frameworks directory

Sourceval copy_to_resources : t -> src:OpamFilename.t -> relative_path:string -> OpamFilename.t

copy_to_resources bundle ~src ~relative_path copies a file to Resources/relative_path/basename(src). Creates the relative_path subdirectory if it doesn't exist