yb85 / scantailor-advanced-osx

Homebrew formula and App bundler for Scantailor (Advanced)
150 stars 6 forks source link

Bundler creates bad bundle on Apple Silicon with macOS Sonoma #20

Open AthanasiusOfAlex opened 12 months ago

AthanasiusOfAlex commented 12 months ago

I tried this both with the release and the HEAD versions.

I was able to compile Scantailor with no trouble and I can use it from the command line with no issues.

The scantailor_bundler.command claims to succeed. However, when I try to use the bundle, it immediately crashes, I assume because the linking with Qt is not done correctly.

In scantailor_bundler.command, everything appears to work correctly until the line

$qtprefix/bin/macdeployqt  "$TARGET"  -libpath="$qtprefix/lib"

At that point, there are a lot of messages like

ERROR: Cannot resolve rpath "@rpath/QtOpenGL.framework/Versions/A/QtOpenGL"
ERROR:  using QList("/path/to/repository/scantailor-advanced-osx/bundler/lib")

I believe this is a known issue and that the following code is a work-around:

#DIRTY FIX FOR @rpath LINKING ISSUE
cp -R $qtprefix/lib/QtDBus.framework "$TARGET/Contents/Frameworks"
set dbuslib (otool -L "$TARGET/Contents/Frameworks/QtDBus.framework/Versions/A/QtDBus" | grep -Eo "^.*/libdbus-[0-9.]+.dylib" | xargs)
cp "$dbuslib" "$TARGET/Contents/Frameworks/"(basename $dbuslib)
install_name_tool -change "$dbuslib" "@executable_path/../Frameworks/"(basename $dbuslib) "$TARGET/Contents/Frameworks/QtDBus.framework/Versions/A/QtDBus"

I think the error is in this last bit, either because Sonoma made changes something, or because of some difference in Apple Silicon with respect to Intel.