From 8b2bf56eca0745ca9aa872505a3a2acd4f02553f Mon Sep 17 00:00:00 2001 From: Kyle Neideck Date: Thu, 25 Apr 2024 08:46:54 +1000 Subject: [PATCH] Fix Gatekeeper stopping BGMXPCHelper from launching on macOS 14. Also, build the ListInputDevices tool as a universal binary. Contributed by modue sp. z o.o.. --- package.sh | 8 +++++++- pkg/postinstall | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/package.sh b/package.sh index 7d8ee09..36ef88b 100755 --- a/package.sh +++ b/package.sh @@ -21,6 +21,7 @@ # # Copyright © 2017-2022 Kyle Neideck # Copyright © 2016, 2017 Takayama Fumihiko +# Copyright © 2023 modue sp. z o.o. # # Builds Background Music and packages it into a .pkg file. Call this script with -d to use the # debug build configuration. @@ -141,7 +142,12 @@ fi echo "Compiling ListInputDevices" if ! [[ $packaging_operation == "repackage" ]]; then - swiftc pkg/ListInputDevices.swift -o pkg/ListInputDevices + echo "Compiling ListInputDevices" + swiftc pkg/ListInputDevices.swift -o pkg/ListInputDevices-x86_64 -target x86_64-apple-macos13.0 + swiftc pkg/ListInputDevices.swift -o pkg/ListInputDevices-arm64 -target arm64-apple-macos13.0 + # Combine the x86_64 and arm64 binaries into a universal binary. + lipo -create pkg/ListInputDevices-x86_64 pkg/ListInputDevices-arm64 -output pkg/ListInputDevices + rm pkg/ListInputDevices-x86_64 pkg/ListInputDevices-arm64 fi # -------------------------------------------------- diff --git a/pkg/postinstall b/pkg/postinstall index ed775c9..88aa179 100644 --- a/pkg/postinstall +++ b/pkg/postinstall @@ -20,6 +20,7 @@ # postinstall # # Copyright © 2017-2022, 2024 Kyle Neideck +# Copyright © 2023 modue sp. z o.o. # # Make sure we use the built-in versions of programs, for consistency. Probably not necessary @@ -44,6 +45,15 @@ log "Installing BGMXPCHelper to $xpc_helper_install_path" rm -rf "${xpc_helper_install_path}/BGMXPCHelper.xpc" cp -Rf "BGMXPCHelper.xpc" "$xpc_helper_install_path" +# Remove the quarantine attribute from BGMXPCHelper. Since macOS 14.0, this is needed to keep +# Gatekeeper from trying to show a permission prompt when BGMXPCHelper is launched. That would +# fail because BGMXPCHelper is a daemon, and Gatekeeper would prevent it from launching. +# +# TODO: I think, ideally, we should use the new Service Management API to install BGMXPCHelper, +# which would probably avoid this issue. See +# . +sudo xattr -d com.apple.quarantine "${xpc_helper_install_path}/BGMXPCHelper.xpc" + # TODO: Fail the install and show an error message if this fails. bash "post_install.sh" "$xpc_helper_install_path" "BGMXPCHelper.xpc/Contents/MacOS/BGMXPCHelper" "."