Skip to content

The agent that grows with you

fix(desktop): pin macosx SDK for the screenshot-monitor native build

Yagna Vudathu5bb1ded87999
diff --git a/apps/desktop/scripts/build-command-screenshot-monitor.mjs b/apps/desktop/scripts/build-command-screenshot-monitor.mjs
index 7aef6368694..b59ce9be2c7 100644
--- a/apps/desktop/scripts/build-command-screenshot-monitor.mjs
+++ b/apps/desktop/scripts/build-command-screenshot-monitor.mjs
@@ -14,7 +14,12 @@ export function buildCommandScreenshotMonitor({ distDir = resolve(root, 'dist')
const staging = `${output}.${process.pid}.tmp`
mkdirSync(dirname(output), { recursive: true })
try {
+ // Pin the SDK explicitly: a bare `xcrun clang` inherits the host default
+ // SDK, which may be newer than the active linker (unknown-arch .tbd stubs
+ // at link time, #113708). `--sdk macosx` names the same default SDK while
+ // forcing the driver and linker to agree on it.
execFileSync('xcrun', [
+ '--sdk', 'macosx',
'clang', '-arch', 'arm64', '-arch', 'x86_64', '-mmacosx-version-min=11.0',
'-fobjc-arc', '-fblocks', '-O2', '-Wall', '-Wextra',
'-framework', 'Cocoa', '-framework', 'CoreGraphics',
diff --git a/apps/desktop/scripts/build-command-screenshot-monitor.test.mjs b/apps/desktop/scripts/build-command-screenshot-monitor.test.mjs
new file mode 100644
index 00000000000..9c5526613b6
--- /dev/null
+++ b/apps/desktop/scripts/build-command-screenshot-monitor.test.mjs
@@ -0,0 +1,33 @@
+import fs from 'node:fs'
+import os from 'node:os'
+import path from 'node:path'
+import { describe, expect, it, vi } from 'vitest'
+
+vi.mock('node:child_process', () => ({
+ execFileSync: vi.fn(),
+}))
+
+const { execFileSync } = await import('node:child_process')
+const { buildCommandScreenshotMonitor } = await import('./build-command-screenshot-monitor.mjs')
+
+// The helper shells out to xcrun; pin the argv contract (not the toolchain).
+describe('buildCommandScreenshotMonitor argv', () => {
+ it('names the macOS SDK explicitly so driver and linker agree (#113708)', () => {
+ if (process.platform !== 'darwin') {
+ return
+ }
+ const distDir = fs.mkdtempSync(path.join(os.tmpdir(), 'csm-argv-'))
+ const staging = path.resolve(distDir, `native/command-screenshot-monitor.${process.pid}.tmp`)
+ fs.mkdirSync(path.dirname(staging), { recursive: true })
+ fs.writeFileSync(staging, 'staged')
+
+ const out = buildCommandScreenshotMonitor({ distDir })
+
+ expect(execFileSync).toHaveBeenCalledOnce()
+ const [cmd, argv] = execFileSync.mock.calls[0]
+ expect(cmd).toBe('xcrun')
+ expect(argv.slice(0, 3)).toEqual(['--sdk', 'macosx', 'clang'])
+ expect(out).toBe(path.resolve(distDir, 'native/command-screenshot-monitor'))
+ fs.rmSync(distDir, { recursive: true, force: true })
+ })
+})