#!/bin/sh # cmake/macos/fixup-libobs-rpath.sh # # The from-source libobs build this project's macOS bootstrap runs # (cmake/common/buildspec_common.cmake) records its own install name (its # LC_ID_DYLIB) as a relative path -- "libobs/libobs.framework/Versions/A/libobs" # -- rather than an @rpath reference. That is a property of that from-source # OBS build itself, not something this project's own link step controls: the # LC_LOAD_DYLIB entry our plugin binary gets for a dependency is copied # straight from that dependency's own LC_ID_DYLIB by the linker. A relative # path is not resolvable at runtime from inside an OBS.app plugin bundle -- # see the "macOS packaging gap" this script fixes, documented in README.md. # # Rewrite that one dependency entry to @rpath/libobs.framework/Versions/A/libobs. # stplugin_macos_finalize_bundle() (cmake/macos/helpers.cmake) gives the # plugin binary an LC_RPATH of @executable_path/../Frameworks, which resolves # @rpath against the *host* OBS.app's own Contents/Frameworks/libobs.framework # at runtime (@executable_path is always relative to the process's main # executable -- OBS.app/Contents/MacOS/obs -- not to this dlopen'd bundle, no # matter how deeply the .plugin is nested under # ~/Library/Application Support/obs-studio/plugins//bin/). # # The LiveKit runtime dylibs this same helper copies into the bundle's own # Contents/Frameworks are NOT touched here: client-sdk-cpp's own release # build already records their install names as @rpath references (confirmed # by otool -L on prior CI runs -- see README's "Where the macOS bootstrap # actually got to"), so the @loader_path/../Frameworks half of the same # LC_RPATH already resolves them with no rewrite needed. set -eu binary="$1" if [ ! -f "$binary" ]; then echo "fixup-libobs-rpath: no such file: $binary" >&2 exit 1 fi old_ref=$(otool -L "$binary" \ | awk '/libobs\.framework\/Versions\/A\/libobs/ && $1 !~ /^@rpath/ {print $1; exit}') if [ -n "${old_ref:-}" ]; then echo "fixup-libobs-rpath: rewriting '$old_ref' -> '@rpath/libobs.framework/Versions/A/libobs' in $binary" install_name_tool -change "$old_ref" "@rpath/libobs.framework/Versions/A/libobs" "$binary" else echo "fixup-libobs-rpath: libobs dependency in $binary is already @rpath-relative (or was not found via otool -L); nothing to rewrite" fi