Xcode status monitor for terminal - captures your current file, selection, and build errors as context for Claude Code.
- Xcode Status: Shows whether Xcode is running and which project is active
- Current File Tracking: Displays the currently open file in Xcode with clickable file links
- Selection Tracking: Shows number of lines selected and their content
- Build Error Detection: Monitors Xcode build logs and reports build errors
- Detailed Error Messages: Extracts and displays Swift compilation errors with file locations
- Claude Code Integration: Provides context for AI-assisted development
npm install -g claude-xcode-contextGet current Xcode status:
claude-xcode-contextOutput example:
π’ ExampleApp
β§ In ContentView.swift
13 lines selected (10-22)
--- Context ---
Project Path: /Users/you/ExampleApp/ExampleApp.xcworkspace
File Path: /Users/you/ExampleApp/Sources/ContentView.swift
--- Selected Code ---
10: struct ContentView: View {
11: var body: some View {
12: Text("Hello, World!")
...
# Show help
claude-xcode-context --help
claude-xcode-context -h
# Show version
claude-xcode-context --version
claude-xcode-context -v
# Use custom Xcode app name (e.g., Xcode-beta)
claude-xcode-context --xcode Xcode-beta
claude-xcode-context -x Xcode-betaThe tool writes Xcode context to:
~/.claude-xcode-build-infra/statusline_context.json
This file contains:
- Current file and path
- Selected line range (
selection_start,selection_end,selected_lines) - Build errors with detailed messages
- Project information
Use the /xcode-context command in Claude Code to leverage this context for AI-assisted development.
π΄ Xcode closed, open now
π’ Xcode opened but not focused
0 lines selected
π’ ExampleApp
β§ In ContentView.swift
15 lines selected (42-56)
--- Context ---
Project Path: /Users/you/ExampleApp/ExampleApp.xcworkspace
File Path: /Users/you/ExampleApp/Sources/ContentView.swift
--- Selected Code ---
42: func fetchData() {
43: // Implementation
...
π’ ExampleApp
β§ In ContentView.swift
3 build errors
--- Build Errors ---
ContentView.swift:23:15: error: Cannot find 'invalidFunction' in scope
ViewModel.swift:45:9: error: Value of type 'String' has no member 'invalidProperty'
...
Note: File names are clickable links in supported terminals (iTerm2, Terminal.app with Cmd+Click)
The tool is organized into focused modules:
lib/
cli/
options.js - CLI configuration
handlers.js - Command handlers
constants.js - Configuration constants
applescript-bridge.js - AppleScript execution
xcode-project-finder.js - Project/file resolution
build-error-parser.js - Build log parsing
status-collector.js - Main orchestration
output-formatter.js - Terminal formatting
selection-handler.js - Code selection
persistence.js - Log file I/O
The tool monitors Xcode's build logs in ~/Library/Developer/Xcode/DerivedData:
- Matches the active project with its DerivedData folder
- Reads
LogStoreManifest.plistto find the latest build - Parses compressed build logs to extract Swift compilation errors
- Filters out warnings and focuses on actual errors
- Formats error messages with file:line:column locations
Multiple strategies are used to resolve the current file path:
- Query Xcode's active source document via AppleScript
- Parse window title to extract filename
- Search project directory using
findcommand - Try common source directory patterns (Sources, src)
- AppleScript calls have configurable timeouts (2-5 seconds)
- File operations are optimized with early exits
- Compressed log decompression handled efficiently
- Single execution model (no continuous polling)
- macOS: This package only works on macOS (darwin)
- Node.js: >= 18.3.0 (for native
parseArgsAPI) - Xcode: Any version that uses DerivedData
The JSON file at ~/.claude-xcode-build-infra/statusline_context.json contains:
{
"timestamp": "2025-01-05T10:30:45.123Z",
"xcode_running": true,
"project_name": "ExampleApp",
"project_path": "/Users/you/ExampleApp/ExampleApp.xcworkspace",
"current_file": "ContentView.swift",
"current_file_path": "/Users/you/ExampleApp/Sources/ContentView.swift",
"selected_lines": 13,
"selection_start": 10,
"selection_end": 22,
"build_errors": 0,
"detailed_errors": []
}bin/
statusline.js - CLI entry point (61 lines)
lib/
cli/ - CLI argument handling
constants.js - Configuration
applescript-bridge.js - AppleScript utilities
build-error-parser.js - Error extraction
xcode-project-finder.js - Path resolution
status-collector.js - Status orchestration
output-formatter.js - Terminal output
selection-handler.js - Selection handling
persistence.js - File I/O
- Add option to
lib/cli/options.js - Add handler to
lib/cli/handlers.js - Use in
bin/statusline.js
# Run with your local Xcode
node bin/statusline.js
# Test with custom Xcode
node bin/statusline.js --xcode Xcode-beta
# Check version
node bin/statusline.js --version- Ensure Xcode is the foreground app
- Try using
--xcodeflag if using Xcode-beta or custom name - Check Xcode's Accessibility permissions in System Settings
- Make sure a file is open and focused in Xcode
- The file must be part of the active project
- Try clicking in the editor to focus the file
- Errors appear only after a build (βB)
- Make sure the build failed (not warnings)
- Check that DerivedData is in the default location
leocoout
https://github.com/leocoout/claude-xcode-context
MIT