UNPKG

xc-mcp

Version:

MCP server that wraps Xcode command-line tools for iOS/macOS development workflows

92 lines 3.38 kB
/** * Build Artifacts Discovery * * Utilities for finding and analyzing Xcode build artifacts (.app bundles, dSYMs, etc.) * Uses build settings cache to determine artifact locations without manual path specification. */ import { buildSettingsCache } from '../state/build-settings-cache.js'; import { existsSync } from 'fs'; import { join } from 'path'; /** * Find build artifacts for a given project and scheme * * Returns paths to .app bundle, dSYM, and other build outputs. * Uses build settings cache to determine locations automatically. * * @param projectPath - Path to .xcodeproj or .xcworkspace * @param scheme - Build scheme name * @param configuration - Build configuration (Debug, Release, etc.) * @returns Object containing paths to build artifacts * * @example * const artifacts = await findBuildArtifacts( * '/path/to/MyApp.xcodeproj', * 'MyApp', * 'Debug' * ); * // Returns: { * // appPath: '/path/to/DerivedData/.../MyApp.app', * // bundleIdentifier: 'com.example.MyApp', * // ... * // } */ export async function findBuildArtifacts(projectPath, scheme, configuration = 'Debug') { // Get build settings from cache const settings = await buildSettingsCache.getBuildSettings(projectPath, scheme, configuration); const buildDir = settings.CONFIGURATION_BUILD_DIR; const productName = settings.PRODUCT_NAME; // Construct artifact paths const appPath = join(buildDir, `${productName}.app`); const dSYMPath = join(buildDir, `${productName}.app.dSYM`); // Verify .app exists (build may not have run yet) const appExists = existsSync(appPath); return { appPath: appExists ? appPath : undefined, dSYMPath: existsSync(dSYMPath) ? dSYMPath : undefined, bundleIdentifier: settings.PRODUCT_BUNDLE_IDENTIFIER, buildDirectory: buildDir, }; } /** * Verify build artifacts exist for installation * * Checks that .app bundle exists and is ready for installation to simulator. * Provides helpful error messages if artifacts are missing. * * @param projectPath - Path to .xcodeproj or .xcworkspace * @param scheme - Build scheme name * @param configuration - Build configuration * @returns Validation result with app path or error guidance */ export async function verifyBuildArtifacts(projectPath, scheme, configuration = 'Debug') { try { const artifacts = await findBuildArtifacts(projectPath, scheme, configuration); if (!artifacts.appPath) { return { valid: false, error: 'App bundle not found', guidance: [ 'Build the project first using xcodebuild-build', `Expected location: ${artifacts.buildDirectory}`, 'Verify build succeeded before attempting installation', ], }; } return { valid: true, appPath: artifacts.appPath, }; } catch (error) { return { valid: false, error: `Could not determine build artifacts: ${error}`, guidance: [ 'Ensure project path and scheme are correct', 'Check build settings are accessible', 'Try: xcodebuild-list to see available schemes', ], }; } } //# sourceMappingURL=build-artifacts.js.map