Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: align macOS desktop bundles with their supported system version
Richie McIlroy5a67fd28f0d3
diff --git a/apps/desktop-gpui/resources/Info.plist b/apps/desktop-gpui/resources/Info.plistindex dd8348c74..b9ee3ed15 100644--- a/apps/desktop-gpui/resources/Info.plist+++ b/apps/desktop-gpui/resources/Info.plist@@ -53,7 +53,7 @@<key>LSApplicationCategoryType</key><string>public.app-category.productivity</string><key>LSMinimumSystemVersion</key>- <string>11.0</string>+ <string>12.3</string><key>NSHighResolutionCapable</key><true/><key>NSCameraUsageDescription</key>diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.jsonindex f31590d46..08ca98268 100644--- a/apps/desktop/src-tauri/tauri.conf.json+++ b/apps/desktop/src-tauri/tauri.conf.json@@ -67,6 +67,7 @@"../src/assets/music/*.mp3": "assets/music/"},"macOS": {+ "minimumSystemVersion": "12.3","dmg": {"background": "assets/dmg-background.png","appPosition": {diff --git a/scripts/build-gpui-binary.sh b/scripts/build-gpui-binary.shindex e8e276e22..2db415334 100755--- a/scripts/build-gpui-binary.sh+++ b/scripts/build-gpui-binary.sh@@ -35,6 +35,11 @@ elsefiextension=""+if [[ "$target" == *-apple-darwin ]]; then+ MACOSX_DEPLOYMENT_TARGET="$(node "$repo_root/scripts/build-macos-packages.mjs" --deployment-target)"+ export MACOSX_DEPLOYMENT_TARGET+fi+if [[ "$target" == *windows* ]]; thenextension=".exe"fidiff --git a/scripts/build-macos-packages.mjs b/scripts/build-macos-packages.mjsindex 4dedceca5..f166e8fc0 100644--- a/scripts/build-macos-packages.mjs+++ b/scripts/build-macos-packages.mjs@@ -1,4 +1,5 @@import { spawn } from "node:child_process";+import { readFileSync } from "node:fs";import { constants } from "node:os";import path from "node:path";import { setTimeout as wait } from "node:timers/promises";@@ -11,6 +12,38 @@ const desktopDirectory = fileURLToPath(const retryDelays = [15_000, 30_000];const outputTailLimit = 64 * 1024;+export function resolveMacosDeploymentTarget(value) {+ const minimum = JSON.parse(+ readFileSync(+ path.join(desktopDirectory, "src-tauri/tauri.conf.json"),+ "utf8",+ ),+ ).bundle.macOS.minimumSystemVersion;+ const target = value || minimum;+ const parseVersion = (version) => {+ if (typeof version !== "string" || !/^\d+(?:\.\d+){0,2}$/.test(version)) {+ throw new Error(`Invalid macOS deployment target: ${version}`);+ }+ const parts = version.split(".").map(Number);+ if (!parts.every(Number.isSafeInteger)) {+ throw new Error(`Invalid macOS deployment target: ${version}`);+ }+ return parts;+ };+ const required = parseVersion(minimum);+ const requested = parseVersion(target);+ for (let index = 0; index < 3; index++) {+ const difference = (requested[index] ?? 0) - (required[index] ?? 0);+ if (difference > 0) return target;+ if (difference < 0) {+ throw new Error(+ `MACOSX_DEPLOYMENT_TARGET=${target} is below Cap's minimum macOS version ${minimum}; ScreenCaptureKit requires macOS 12.3 or later.`,+ );+ }+ }+ return target;+}+export function isTimestampSigningFailure(output) {const lines = stripVTControlCharacters(output).split(/\r?\n/)@@ -124,7 +157,23 @@ export async function buildMacosPackages() {validateArguments(target, args, platform);const commandArguments = ["--target", target, ...args];- const environment = { ...env, RUST_TARGET_TRIPLE: target };+ const environment = {+ ...env,+ RUST_TARGET_TRIPLE: target,+ MACOSX_DEPLOYMENT_TARGET: resolveMacosDeploymentTarget(+ env.MACOSX_DEPLOYMENT_TARGET,+ ),+ };+ commandArguments.push(+ "--config",+ JSON.stringify({+ bundle: {+ macOS: {+ minimumSystemVersion: environment.MACOSX_DEPLOYMENT_TARGET,+ },+ },+ }),+ );for (let attempt = 0; ; attempt++) {signal?.throwIfAborted();let outputTail = "";@@ -171,13 +220,19 @@ export async function buildMacosPackages(}async function main() {+ const [target, ...args] = process.argv.slice(2);+ if (target === "--deployment-target" && args.length === 0) {+ console.log(+ resolveMacosDeploymentTarget(process.env.MACOSX_DEPLOYMENT_TARGET),+ );+ return;+ }const controller = new AbortController();const interrupt = () => controller.abort("SIGINT");const terminate = () => controller.abort("SIGTERM");process.on("SIGINT", interrupt);process.on("SIGTERM", terminate);try {- const [target, ...args] = process.argv.slice(2);const result = await buildMacosPackages(target, args, {signal: controller.signal,});diff --git a/scripts/build-macos-packages.test.mjs b/scripts/build-macos-packages.test.mjsindex ad8c44956..22d2ae142 100644--- a/scripts/build-macos-packages.test.mjs+++ b/scripts/build-macos-packages.test.mjs@@ -1,11 +1,13 @@import assert from "node:assert/strict";import { EventEmitter } from "node:events";+import { readFileSync } from "node:fs";import { PassThrough } from "node:stream";import test from "node:test";import {buildMacosPackages,executeMacosCommand,isTimestampSigningFailure,+ resolveMacosDeploymentTarget,} from "./build-macos-packages.mjs";const target = "x86_64-apple-darwin";@@ -58,6 +60,122 @@ function harness(results) {};}+test("macOS packaging uses the ScreenCaptureKit minimum across both app manifests", () => {+ const minimum = resolveMacosDeploymentTarget();+ assert.equal(minimum, "12.3");+ assert.equal(resolveMacosDeploymentTarget(""), minimum);+ const cargo = readFileSync(+ new URL("../apps/desktop-gpui/Cargo.toml", import.meta.url),+ "utf8",+ );+ const plist = readFileSync(+ new URL("../apps/desktop-gpui/resources/Info.plist", import.meta.url),+ "utf8",+ );+ assert.equal(+ cargo.match(/osx_minimum_system_version\s*=\s*"([^"]+)"/)?.[1],+ minimum,+ );+ assert.equal(+ plist.match(+ /<key>LSMinimumSystemVersion<\/key>\s*<string>([^<]+)<\/string>/,+ )?.[1],+ minimum,+ );+});++test("macOS deployment targets preserve compatible overrides and reject unsafe versions", () => {+ for (const version of ["12.3", "12.3.0", "12.3.1", "12.10", "13", "15.7"]) {+ assert.equal(resolveMacosDeploymentTarget(version), version);+ }+ for (const version of ["10.13", "11.0", "12", "12.2.99"]) {+ assert.throws(+ () => resolveMacosDeploymentTarget(version),+ /below Cap's minimum/,+ );+ }+ for (const version of [+ "abc",+ "12.3beta",+ "12.3.0.0",+ "-1",+ "99999999999999999999",+ ]) {+ assert.throws(+ () => resolveMacosDeploymentTarget(version),+ /Invalid macOS deployment target/,+ );+ }+});++test("a higher macOS target reaches every build and rebundle with matching installer metadata", async () => {+ for (const architecture of [target, "aarch64-apple-darwin"]) {+ const fixture = harness([+ { code: 1, output: intelTimestampFailure },+ { code: 0 },+ ]);+ fixture.options.env.MACOSX_DEPLOYMENT_TARGET = "14.0";+ assert.equal(+ (await buildMacosPackages(architecture, config, fixture.options)).code,+ 0,+ );+ for (const call of fixture.calls) {+ assert.equal(call.env.MACOSX_DEPLOYMENT_TARGET, "14.0");+ assert.deepEqual(JSON.parse(call.args.at(-1)), {+ bundle: { macOS: { minimumSystemVersion: "14.0" } },+ });+ }+ assert.equal(fixture.options.env.RUST_TARGET_TRIPLE, "previous-target");+ }+});++test("an unsupported macOS override fails before starting a compiler or packager", async () => {+ const fixture = harness([]);+ fixture.options.env.MACOSX_DEPLOYMENT_TARGET = "10.13";+ await assert.rejects(+ buildMacosPackages(target, config, fixture.options),+ /below Cap's minimum macOS version 12.3/,+ );+ assert.deepEqual(fixture.calls, []);+});++test("caller configs cannot lower the validated build target in final bundle metadata", async () => {+ for (const deploymentTarget of [undefined, "14.0"]) {+ const fixture = harness([+ { code: 1, output: intelTimestampFailure },+ { code: 0 },+ ]);+ fixture.options.env.MACOSX_DEPLOYMENT_TARGET = deploymentTarget;+ const lowerConfig = JSON.stringify({+ bundle: { macOS: { minimumSystemVersion: "10.13" } },+ });+ const callerArguments = [+ ...config,+ "--config",+ lowerConfig,+ `--config=${lowerConfig}`,+ ];+ assert.equal(+ (await buildMacosPackages(target, callerArguments, fixture.options)).code,+ 0,+ );+ for (const call of fixture.calls) {+ assert.deepEqual(call.args.slice(-2), [+ "--config",+ JSON.stringify({+ bundle: {+ macOS: { minimumSystemVersion: deploymentTarget ?? "12.3" },+ },+ }),+ ]);+ assert.equal(+ call.env.MACOSX_DEPLOYMENT_TARGET,+ deploymentTarget ?? "12.3",+ );+ }+ }+});+test("recognizes the observed Intel and ARM signing failures with pnpm and ANSI output", () => {assert.equal(isTimestampSigningFailure(intelTimestampFailure), true);assert.equal(isTimestampSigningFailure(armTimestampFailure), true);@@ -116,6 +234,10 @@ test("timestamp retries only rebundle and preserve the target, config and signinconst args = [...config, "--config", "extra config.json", "--verbose"];const result = await buildMacosPackages(target, args, fixture.options);assert.equal(result.code, 0);+ const minimumConfig = [+ "--config",+ JSON.stringify({ bundle: { macOS: { minimumSystemVersion: "12.3" } } }),+ ];const bundleArguments = ["exec","dotenv",@@ -128,11 +250,12 @@ test("timestamp retries only rebundle and preserve the target, config and signin"--target",target,...args,+ ...minimumConfig,];assert.deepEqual(fixture.calls.map((call) => call.args),[- ["build:tauri", "--target", target, ...args],+ ["build:tauri", "--target", target, ...args, ...minimumConfig],bundleArguments,bundleArguments,],@@ -141,6 +264,7 @@ test("timestamp retries only rebundle and preserve the target, config and signinassert.deepEqual(call.env, {...fixture.options.env,RUST_TARGET_TRIPLE: target,+ MACOSX_DEPLOYMENT_TARGET: "12.3",});}assert.deepEqual(fixture.delays, [15_000, 30_000]);diff --git a/scripts/bundle-gpui-mac b/scripts/bundle-gpui-macindex 6b41c87f7..449f6f00b 100755--- a/scripts/bundle-gpui-mac+++ b/scripts/bundle-gpui-mac@@ -12,6 +12,8 @@ info_plist="$gpui_dir/resources/Info.plist"entitlements="$repo_root/apps/desktop/src-tauri/Entitlements.plist"target_triple="$(rustc -vV | awk '/^host:/ { host = $2 } END { print host }')"sidecars="$repo_root/apps/desktop/src-tauri/binaries"+MACOSX_DEPLOYMENT_TARGET="$(node "$repo_root/scripts/build-macos-packages.mjs" --deployment-target)"+export MACOSX_DEPLOYMENT_TARGETif [[ "$target_dir" != /* ]]; thentarget_dir="$gpui_dir/$target_dir"@@ -53,6 +55,18 @@ if [[ ! -x "$binary_path" ]]; thenexit 1fi+app_version="$(cd "$gpui_dir" && cargo metadata --locked --offline --no-deps --format-version 1 | node -e '+let input = "";+process.stdin.setEncoding("utf8");+process.stdin.on("data", chunk => input += chunk);+process.stdin.on("end", () => {+ const pkg = JSON.parse(input).packages.find(pkg => pkg.name === "cap-desktop-gpui");+ const version = pkg?.version.match(/^(\d+\.\d+\.\d+)(?:[-+].*)?$/)?.[1];+ if (!version) throw new Error("Missing or invalid GPUI package version");+ console.log(version);+});+')"+app_path="$target_dir/release/bundle/osx/Cap GPUI.app"contents="$app_path/Contents"@@ -60,6 +74,9 @@ rm -rf "$app_path"mkdir -p "$contents/MacOS" "$contents/Frameworks" "$contents/Resources/assets"/usr/bin/ditto "$binary_path" "$contents/MacOS/cap-gpui"/usr/bin/ditto "$info_plist" "$contents/Info.plist"+/usr/libexec/PlistBuddy -c "Set :LSMinimumSystemVersion $MACOSX_DEPLOYMENT_TARGET" "$contents/Info.plist"+/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $app_version" "$contents/Info.plist"+/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $app_version" "$contents/Info.plist"/usr/bin/ditto "$icon" "$contents/Resources/icon.icns"rm -rf "$contents/Frameworks/Spacedrive.framework"/usr/bin/ditto "$framework" "$contents/Frameworks/Spacedrive.framework"