Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(mac): bundle only target release sidecars

Louis Beaumont85bffd255187
diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml
index de6e630ca..99b45ffce 100644
--- a/.github/workflows/release-app.yml
+++ b/.github/workflows/release-app.yml
@@ -690,6 +690,34 @@ jobs:
echo "args=$ARGS" >> $GITHUB_OUTPUT
echo "Final tauri args: $ARGS"
+ - name: Select macOS sidecar bundle entries
+ if: matrix.os_type == 'macos'
+ shell: bash
+ run: |
+ set -euo pipefail
+ TARGET="${{ matrix.target }}"
+ node <<'NODE'
+ const fs = require("fs");
+ const path = "apps/screenpipe-app-tauri/src-tauri/tauri.macos.conf.json";
+ const target = process.env.TARGET;
+ const config = JSON.parse(fs.readFileSync(path, "utf8"));
+ config.bundle ??= {};
+ config.bundle.macOS ??= {};
+ if (target === "aarch64-apple-darwin") {
+ config.bundle.macOS.files = { "MacOS/mlx.metallib": "mlx.metallib" };
+ } else if (target === "x86_64-apple-darwin") {
+ config.bundle.macOS.files = {
+ "MacOS/libonnxruntime.dylib": "libonnxruntime.dylib",
+ };
+ } else {
+ throw new Error(`unknown macOS release target: ${target}`);
+ }
+ fs.writeFileSync(path, `${JSON.stringify(config, null, 2)}\n`);
+ console.log(`macOS bundle sidecars selected for ${target}`);
+ NODE
+ env:
+ TARGET: ${{ matrix.target }}
+
- name: Re-unlock build keychain before signing (macOS)
if: matrix.os_type == 'macos'
shell: bash
@@ -1069,8 +1097,8 @@ jobs:
# build-keychain dance (the `errSecInternalComponent` class — see
# the keychain setup above) only surfaces as a notarization failure
# much later in the workflow.
- # Covers the single Tauri codesign pass (mlx.metallib / libonnxruntime.dylib
- # are staged into Contents/MacOS/ at build time via bundle.macOS.files).
+ # Covers the single Tauri codesign pass for the architecture-specific
+ # sidecar staged into Contents/MacOS/ via bundle.macOS.files.
if: matrix.os_type == 'macos'
shell: bash
run: |
diff --git a/apps/screenpipe-app-tauri/src-tauri/build.rs b/apps/screenpipe-app-tauri/src-tauri/build.rs
index e2d09618b..ed82c70a2 100644
--- a/apps/screenpipe-app-tauri/src-tauri/build.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/build.rs
@@ -565,13 +565,22 @@ fn stage_macos_sidecar_libs() {
stage_libonnxruntime_dylib();
}
-/// Copy mlx.metallib to a known location so Tauri can bundle it via bundle.macOS.files.
-/// MLX compiles Metal shaders into this file during mlx-sys build. Without it,
-/// parakeet-mlx crashes with "Failed to load the default metallib".
-#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
+/// Copy mlx.metallib to a known location so Tauri can bundle it via
+/// bundle.macOS.files on aarch64 macOS release builds. MLX compiles Metal
+/// shaders into this file during mlx-sys build. Without it, parakeet-mlx
+/// crashes with "Failed to load the default metallib".
+#[cfg(target_os = "macos")]
fn stage_mlx_metallib() {
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let metallib = std::path::Path::new(&manifest_dir).join("mlx.metallib");
+ let target_arch =
+ std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| "aarch64".to_string());
+
+ if target_arch != "aarch64" {
+ let _ = std::fs::remove_file(&metallib);
+ return;
+ }
+
let min_size = 1_000_000; // real metallib is ~84MB
let needs_download = !metallib.exists()
@@ -607,18 +616,6 @@ fn stage_mlx_metallib() {
sign_macos_sidecar_if_needed(&metallib);
}
-/// Ensure mlx.metallib exists so Tauri doesn't fail on the bundle.macOS.files entry.
-/// On non-aarch64-macOS builds, create an empty placeholder (it won't be used).
-#[cfg(all(target_os = "macos", not(target_arch = "aarch64")))]
-fn stage_mlx_metallib() {
- let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
- let metallib = std::path::Path::new(&manifest_dir).join("mlx.metallib");
- // Truncate any cached real metallib from a previous arm64 build. The
- // non-arm64 bundle entry is only a placeholder so Tauri's macOS.files entry
- // resolves; stale nested code in Contents/MacOS breaks app signing.
- let _ = std::fs::write(&metallib, b"");
-}
-
/// Stage libonnxruntime.dylib for x86_64 Intel builds. ort `load-dynamic` resolves
/// relative paths from the executable, so the dylib must live in Contents/MacOS/.
#[cfg(target_os = "macos")]
@@ -673,10 +670,7 @@ fn stage_libonnxruntime_dylib() {
}
sign_macos_sidecar_if_needed(&dylib);
} else {
- // Truncate any cached real dylib from a previous x86_64 build. The
- // non-x86_64 bundle entry is only a placeholder so Tauri's macOS.files
- // entry resolves; stale nested code in Contents/MacOS breaks app signing.
- let _ = std::fs::write(&dylib, b"");
+ let _ = std::fs::remove_file(&dylib);
}
}