Skip to content

Commit f80f9ad

Browse files
cameroncookeclaude
andcommitted
fix: resolve bundled AXe path detection and configuration
- Fix path resolution in axe-setup.ts for tsup bundled code - Add @rpath configuration to bundled AXe binary for framework loading - Update diagnostic tool to properly detect bundled AXe availability - Remove DYLD_FRAMEWORK_PATH dependency in favor of @rpath 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a64495e commit f80f9ad

6 files changed

Lines changed: 64 additions & 86 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"scripts": {
1212
"build": "node -e \"const fs = require('fs'); const pkg = require('./package.json'); fs.writeFileSync('src/version.ts', \\`export const version = '\\${pkg.version}';\\nexport const templateVersion = '\\${pkg.templateVersion}';\\n\\`)\" && tsup",
1313
"build:watch": "npm run build && tsup --watch",
14-
"bundle:axe": "scripts/build-axe.sh",
14+
"bundle:axe": "scripts/bundle-axe.sh",
1515
"lint": "eslint 'src/**/*.{js,ts}'",
1616
"lint:fix": "eslint 'src/**/*.{js,ts}' --fix",
1717
"format": "prettier --write 'src/**/*.{js,ts}'",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ if [ -d "$AXE_LOCAL_DIR" ] && [ -f "$AXE_LOCAL_DIR/Package.swift" ]; then
4343
echo "📦 Copying AXe binary..."
4444
cp ".build/release/axe" "$BUNDLED_DIR/"
4545

46+
# Fix rpath to find frameworks in Frameworks/ subdirectory
47+
echo "🔧 Configuring AXe binary rpath for bundled frameworks..."
48+
install_name_tool -add_rpath "@executable_path/Frameworks" "$BUNDLED_DIR/axe"
49+
4650
# Create Frameworks directory and copy frameworks
4751
echo "📦 Copying frameworks..."
4852
mkdir -p "$BUNDLED_DIR/Frameworks"

src/tools/axe.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import {
1616
createAxeNotAvailableResponse,
1717
getAxePath,
1818
getBundledAxeEnvironment,
19-
} from '../utils/axe-setup.js';
20-
import { areAxeToolsAvailable } from '../utils/axe-setup.js';
19+
} from '../utils/axe-helpers.js';
20+
import { areAxeToolsAvailable } from '../utils/axe-helpers.js';
2121
const LOG_PREFIX = '[AXe]';
2222

2323
// Session tracking for describe_ui warnings

src/tools/diagnostic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { ToolResponse } from '../types/common.js';
1818
import { log } from '../utils/logger.js';
1919
import { execSync } from 'child_process';
2020
import { version } from '../version.js';
21-
import { areAxeToolsAvailable } from '../utils/axe-setup.js';
21+
import { areAxeToolsAvailable } from '../utils/axe-helpers.js';
2222
import { isXcodemakeEnabled, isXcodemakeAvailable, doesMakefileExist } from '../utils/xcodemake.js';
2323
import * as os from 'os';
2424
import { ToolGroup, isSelectiveToolsEnabled, listEnabledGroups } from '../utils/tool-groups.js';
@@ -259,7 +259,7 @@ export async function runDiagnosticTool(): Promise<ToolResponse> {
259259
features: {
260260
axe: {
261261
available: axeAvailable,
262-
uiAutomationSupported: axeAvailable && binaryStatus['axe'].available,
262+
uiAutomationSupported: axeAvailable,
263263
},
264264
xcodemake: {
265265
enabled: xcodemakeEnabled,

src/utils/axe-helpers.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* AXe Helper Functions
3+
*
4+
* This utility module provides functions to work with the bundled AXe tool.
5+
* Always uses the bundled version to ensure consistency.
6+
*/
7+
8+
import { existsSync } from 'fs';
9+
import { dirname, join } from 'path';
10+
import { fileURLToPath } from 'url';
11+
import { createTextResponse } from './validation.js';
12+
import { ToolResponse } from '../types/common.js';
13+
14+
// Get bundled AXe path - always use the bundled version for consistency
15+
const __filename = fileURLToPath(import.meta.url);
16+
const __dirname = dirname(__filename);
17+
// In the npm package, build/index.js is at the same level as bundled/
18+
// So we go up one level from build/ to get to the package root
19+
const bundledAxePath = join(__dirname, '..', 'bundled', 'axe');
20+
21+
/**
22+
* Get the path to the bundled axe binary
23+
*/
24+
export function getAxePath(): string | null {
25+
// Always use bundled version for consistency
26+
if (existsSync(bundledAxePath)) {
27+
return bundledAxePath;
28+
}
29+
return null;
30+
}
31+
32+
/**
33+
* Get environment variables needed for bundled AXe to run
34+
*/
35+
export function getBundledAxeEnvironment(): Record<string, string> {
36+
// No special environment variables needed - bundled AXe binary
37+
// has proper @rpath configuration to find frameworks
38+
return {};
39+
}
40+
41+
/**
42+
* Check if bundled axe tool is available
43+
*/
44+
export function areAxeToolsAvailable(): boolean {
45+
return getAxePath() !== null;
46+
}
47+
48+
export function createAxeNotAvailableResponse(): ToolResponse {
49+
return createTextResponse(
50+
'Bundled axe tool not found. UI automation features are not available.\n\n' +
51+
'This is likely an installation issue with the npm package.\n' +
52+
'Please reinstall xcodebuildmcp or report this issue.',
53+
true,
54+
);
55+
}

src/utils/axe-setup.ts

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)