Skip to content

Commit bef7ca6

Browse files
committed
Update to latest iOS template
1 parent a577742 commit bef7ca6

4 files changed

Lines changed: 422 additions & 2 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ xcuserdata/
9292

9393
# Claude Config File
9494
**/.claude/settings.local.json
95-
CLAUDE.md
9695

9796
# incremental builds
9897
Makefile

CLAUDE.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
XcodeBuildMCP is a Model Context Protocol (MCP) server that exposes Xcode operations as tools for AI assistants. It enables programmatic interaction with Xcode projects, simulators, devices, and Swift packages through a standardized interface.
8+
9+
## Architecture
10+
11+
### Core Structure
12+
13+
- **Entry Point**: `src/index.ts` - Server initialization, tool registration, and lifecycle management
14+
- **Server Configuration**: `src/server/server.ts` - MCP server setup and transport configuration
15+
- **Tool Organization**: Platform-specific tools in `src/tools/` grouped by functionality:
16+
- Build tools: `build_*.ts`
17+
- Simulator management: `simulator.ts`, `screenshot.ts`, `axe.ts`
18+
- Device management: `device.ts`, `device_log.ts`
19+
- Swift Package Manager: `*-swift-package.ts`
20+
- Project utilities: `discover_projects.ts`, `scaffold.ts`, `clean.ts`
21+
- **Shared Utilities**: `src/utils/` - Command execution, validation, logging, and error handling
22+
- **Type Definitions**: `src/types/common.ts` - Shared interfaces and type definitions
23+
24+
### Key Patterns
25+
26+
1. **Tool Registration**: Tools are registered in `src/utils/register-tools.ts` using a centralized system with workflow-based grouping
27+
2. **Schema Validation**: All tools use Zod schemas for parameter validation before execution
28+
3. **Command Execution**: Standardized pattern using `src/utils/command.ts` for external command execution
29+
4. **Error Handling**: Consistent error wrapping and logging through `src/utils/errors.ts`
30+
5. **Selective Tool Enablement**: Environment variables control which tools are exposed (see `src/utils/tool-groups.ts`)
31+
32+
## Development Commands
33+
34+
```bash
35+
# Install dependencies
36+
npm install
37+
38+
# Build the project
39+
npm run build
40+
41+
# Watch mode for development
42+
npm run build:watch
43+
44+
# Run linting
45+
npm run lint
46+
47+
# Fix linting issues
48+
npm run lint:fix
49+
50+
# Format code
51+
npm run format
52+
53+
# Check formatting
54+
npm run format:check
55+
56+
# Test the server with MCP Inspector
57+
npm run inspect
58+
59+
# Run diagnostic tool
60+
npm run diagnostic
61+
```
62+
63+
## Adding New Tools
64+
65+
When adding a new tool:
66+
67+
1. Create the tool implementation in `src/tools/`
68+
2. Define Zod schema for parameters
69+
3. Follow the existing pattern:
70+
```typescript
71+
export async function myNewTool(params: z.infer<typeof MyToolSchema>): Promise<{ output: string }> {
72+
// Validate parameters
73+
const validated = MyToolSchema.parse(params);
74+
75+
// Execute command using command.ts utilities
76+
const result = await exec(...);
77+
78+
// Return standardized output
79+
return { output: result };
80+
}
81+
```
82+
4. Register the tool in `src/utils/register-tools.ts`
83+
5. Add to appropriate tool group in `src/utils/tool-groups.ts`
84+
6. Update TOOL_OPTIONS.md if adding a new group
85+
7. **Update TOOLS.md** with the new tool's name, MCP tool name, and description in the appropriate category
86+
87+
## Testing
88+
89+
Currently, testing is primarily done through:
90+
- Manual testing with example projects in `example_projects/`
91+
- MCP Inspector for interactive testing (`npm run inspect`)
92+
- Diagnostic tool for environment validation
93+
94+
## Important Implementation Details
95+
96+
### Incremental Builds
97+
- Experimental feature using `xcodemake` instead of `xcodebuild`
98+
- Enabled via `INCREMENTAL_BUILDS_ENABLED` environment variable
99+
- Implementation in `src/utils/xcodemake.ts`
100+
101+
### UI Automation
102+
- Uses bundled AXe tool (`bundled/axe`) for simulator UI interaction
103+
- Coordinates are obtained from UI hierarchy, not screenshots
104+
- Implementation in `src/tools/axe.ts`
105+
106+
### Device Support
107+
- Requires proper code signing configuration in Xcode
108+
- Uses FB frameworks bundled in `bundled/Frameworks/`
109+
- Supports both USB and Wi-Fi connected devices
110+
111+
### Template System
112+
- Project scaffolding templates are external and versioned
113+
- Downloaded on-demand from GitHub releases
114+
- Managed by `src/utils/template-manager.ts`
115+
116+
## Debugging
117+
118+
1. **Server Logs**: Set `LOG_LEVEL=debug` environment variable
119+
2. **MCP Inspector**: Use `npm run inspect` for interactive debugging
120+
3. **Diagnostic Tool**: Run `npm run diagnostic` to check environment
121+
4. **Client Logs**: Check MCP client logs (e.g., Cursor logs in `~/Library/Application Support/Cursor/logs`)
122+
123+
## Contributing Guidelines
124+
125+
1. Follow existing code patterns and structure
126+
2. Use TypeScript strictly - no `any` types
127+
3. Add proper error handling and logging
128+
4. Update documentation for new features
129+
5. **Update TOOLS.md** when adding, modifying, or removing tools
130+
6. Test with example projects before submitting
131+
7. Run lint and format checks before committing
132+
133+
## Tool Documentation
134+
135+
All available tools are comprehensively documented in **TOOLS.md**, which provides:
136+
- Complete list of all 81 tools organized by category
137+
- Tool names and MCP tool names
138+
- Detailed descriptions and parameter requirements
139+
- Common workflow patterns
140+
- Environment variable configuration
141+
142+
## Common Operations Quick Reference
143+
144+
### Build Commands
145+
- macOS: `build_mac_ws`, `build_mac_proj`
146+
- iOS Simulator: `build_sim_name_ws`, `build_sim_id_ws`
147+
- iOS Device: `build_dev_ws`, `build_dev_proj`
148+
- Swift Package: `swift_package_build`
149+
150+
### Run Commands
151+
- macOS: `launch_mac_app`
152+
- iOS Simulator: `launch_app_sim`
153+
- iOS Device: `launch_app_device`
154+
- Swift Package: `swift_package_run`
155+
156+
### Test Commands
157+
- macOS: `test_macos_ws`, `test_macos_proj`
158+
- iOS Simulator: `test_sim_name_ws`, `test_sim_id_ws`
159+
- iOS Device: `test_device_ws`, `test_device_proj`
160+
- Swift Package: `swift_package_test`

0 commit comments

Comments
 (0)