Skip to content

macOS: Hardcoded Homebrew library paths cause crashes #134

@mskayali

Description

@mskayali

Description

The pre-built FFmpeg frameworks for macOS (arm64 architecture) contain hardcoded absolute paths to Homebrew libraries, causing the application to crash on machines that don't have these specific Homebrew packages installed.

Error

dyld: Library not loaded: /opt/homebrew/opt/libiconv/lib/libiconv.2.dylib
  Referenced from: <UUID> /path/to/app.app/Contents/Frameworks/libswresample.framework/Versions/A/libswresample
  Reason: tried: '/opt/homebrew/opt/libiconv/lib/libiconv.2.dylib' (no such file)

Affected Libraries

The frameworks reference these Homebrew libraries with absolute paths:

  • /opt/homebrew/opt/libiconv/lib/libiconv.2.dylib
    • /opt/homebrew/opt/libsamplerate/lib/libsamplerate.0.dylib
      • /opt/homebrew/opt/srt/lib/libsrt.1.5.dylib
        • And others (fontconfig, freetype, fribidi, harfbuzz, glib, etc.)
        • Environment

          • Platform: macOS (arm64/Apple Silicon)
            • FFmpeg Kit Version: 4.1.0 (from release 8.0.0-full-gpl)
              • Frameworks: Downloaded from GitHub releases

Reproduction

  1. Download pre-built macOS frameworks from releases
    1. Integrate into Flutter project
    1. Run on macOS machine without Homebrew or without specific packages
    1. App crashes on launch with dyld error

Investigation

Using otool -L on the frameworks reveals hardcoded absolute Homebrew paths instead of @rpath or system libraries.

Root Cause

The frameworks were likely built on a machine with Homebrew dependencies, and the build process didn't use proper flags to make paths relative or bundle dependencies.

Current Workaround

Install the required Homebrew packages:

brew install libiconv libsamplerate srt

Note: This works for development but not for distribution.

Proposed Solutions

  1. Short-term: Document Homebrew requirements in README
    1. Long-term: Rebuild frameworks with -Wl,-headerpad_max_install_names linker flag and proper dependency bundling

Additional Context

  • x86_64 architecture doesn't have this issue
    • Only arm64 has hardcoded Homebrew paths
      • This significantly affects macOS distribution

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions