find_xcresults
Locate and retrieve all XCResult files for a specified Xcode project, including timestamps and file details, to streamline build analysis and debugging workflows.
Instructions
Find all XCResult files for a specific project with timestamps and file information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| xcodeproj | Yes | Path to the .xcodeproj file (or .xcworkspace if available) - supports both absolute (/path/to/project.xcodeproj) and relative (MyApp.xcodeproj) paths |
Implementation Reference
- src/tools/BuildTools.ts:1359-1402 (handler)The primary handler function that implements the 'find_xcresults' tool logic: validates project path, finds XCResult files in DerivedData/Logs/Test, formats results with timestamps and sizes, provides usage instructionspublic static async findXCResults(projectPath: string): Promise<McpResult> { const validationError = PathValidator.validateProjectPath(projectPath); if (validationError) return validationError; try { const xcresultFiles = await this._findXCResultFiles(projectPath); if (xcresultFiles.length === 0) { return { content: [{ type: 'text', text: `No XCResult files found for project: ${projectPath}\n\nXCResult files are created when you run tests. Try running tests first with 'xcode_test'.` }] }; } let message = `🔍 Found ${xcresultFiles.length} XCResult file(s) for project: ${projectPath}\n\n`; message += `📁 XCResult Files (sorted by newest first):\n`; message += '='.repeat(80) + '\n'; xcresultFiles.forEach((file, index) => { const date = new Date(file.mtime); const timeAgo = this._getTimeAgo(file.mtime); message += `${index + 1}. ${file.path}\n`; message += ` 📅 Created: ${date.toLocaleString()} (${timeAgo})\n`; message += ` 📊 Size: ${this._formatFileSize(file.size || 0)}\n\n`; }); message += `💡 Usage:\n`; message += ` • View results: xcresult-browse --xcresult-path "<path>"\n`; message += ` • Get console: xcresult-browser-get-console --xcresult-path "<path>" --test-id <test-id>\n`; return { content: [{ type: 'text', text: message }] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: 'text', text: `Failed to find XCResult files: ${errorMessage}` }] }; } }
- src/tools/BuildTools.ts:1263-1299 (helper)Supporting helper method that searches the project's DerivedData/Logs/Test directory for .xcresult bundle directories, collects paths with metadata, sorts by recencyprivate static async _findXCResultFiles(projectPath: string): Promise<{ path: string; mtime: number; size?: number }[]> { const xcresultFiles: { path: string; mtime: number; size?: number }[] = []; try { // Use existing BuildLogParser logic to find the correct DerivedData directory const derivedData = await BuildLogParser.findProjectDerivedData(projectPath); if (derivedData) { // Look for xcresult files in the Test logs directory const testLogsDir = join(derivedData, 'Logs', 'Test'); try { const files = await readdir(testLogsDir); const xcresultDirs = files.filter(file => file.endsWith('.xcresult')); for (const xcresultDir of xcresultDirs) { const fullPath = join(testLogsDir, xcresultDir); try { const stats = await stat(fullPath); xcresultFiles.push({ path: fullPath, mtime: stats.mtime.getTime(), size: stats.size }); } catch { // Ignore files we can't stat } } } catch (error) { Logger.debug(`Could not read test logs directory: ${error}`); } } } catch (error) { Logger.warn(`Error finding xcresult files: ${error}`); } return xcresultFiles.sort((a, b) => b.mtime - a.mtime); }
- Tool schema definition for 'find_xcresults' including input schema with xcodeproj parameter (supports preferredXcodeproj default){ name: 'find_xcresults', description: 'Find all XCResult files for a specific project with timestamps and file information', inputSchema: { type: 'object', properties: { xcodeproj: { type: 'string', description: preferredXcodeproj ? `Absolute path to the .xcodeproj file (or .xcworkspace if available) - defaults to ${preferredXcodeproj}` : 'Absolute path to the .xcodeproj file (or .xcworkspace if available) - e.g., /path/to/project.xcodeproj', }, }, required: preferredXcodeproj ? [] : ['xcodeproj'], }, },
- src/XcodeServer.ts:484-488 (registration)MCP server dispatch/registration for 'find_xcresults' tool: parameter validation and delegation to BuildTools.findXCResultscase 'find_xcresults': if (!args.xcodeproj) { throw new McpError(ErrorCode.InvalidParams, `Missing required parameter: xcodeproj`); } return await BuildTools.findXCResults(args.xcodeproj as string);
- src/XcodeServer.ts:921-925 (registration)Direct call dispatch for 'find_xcresults' tool (CLI compatibility): parameter validation and delegation to BuildTools.findXCResultscase 'find_xcresults': if (!args.xcodeproj) { throw new McpError(ErrorCode.InvalidParams, `Missing required parameter: xcodeproj`); } return await BuildTools.findXCResults(args.xcodeproj as string);