
用于Xcode集成的MCP服务器实现
概览
一个MCP(模型上下文协议)服务器,为AI助手提供全面的Xcode集成。该服务器使AI代理能够与Xcode项目交互,管理iOS模拟器,并以增强的错误处理和多种项目类型支持,执行各种Xcode相关任务。 - 设置活跃项目并获取详细项目信息 - 从模板(iOS、macOS、watchOS、tvOS)创建新Xcode项目 - 向Xcode项目添加目标和组规范文件 - 解析工作区文档以查找相关项目 - 列出项目和工作区中的可用方案 - 支持不同编码的读写文件 - 处理带有 base64 编码/解码的二进制文件 - 使用模式和正则表达式搜索文件中的文本内容 - 检查文件存在并获取文件元数据 - 自动创建目录结构 - 构建带有可自定义选项的项目 - 运行带有详细故障报告的测试 - 分析潜在问题的代码 - 干净的构建......
概述(AI 翻译)
一个MCP(模型上下文协议)服务器,为AI助手提供全面的Xcode集成。该服务器使AI代理能够与Xcode项目交互,管理iOS模拟器,并以增强的错误处理和多种项目类型支持,执行各种Xcode相关任务。
特色
项目管理
- 设置活跃项目并获取详细项目信息
- 从模板(iOS、macOS、watchOS、tvOS)创建新的 Xcode 项目
- 向具有目标和组规范的 Xcode 项目添加文件
- 解析工作区文档以查找相关项目
- 列出项目和工作区中的可用方案
文件操作
- 支持不同编码的读写文件
- 处理带有 base64 编码/解码的二进制文件
- 使用模式和正则表达式搜索文件中的文本内容
- 检查文件存在并获取文件元数据
- 自动创建目录结构
构建与测试
- 构建可自定义选项的项目
- 运行带有详细故障报告的测试
- 分析代码潜在问题
- 干净构建目录
- 用于分发的档案项目
CocoaPods 集成
- 在项目中初始化CocoaPods
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Xcode MCP Server
An MCP (Model Context Protocol) server providing comprehensive Xcode integration for AI assistants. This server enables AI agents to interact with Xcode projects, manage iOS simulators, and perform various Xcode-related tasks with enhanced error handling and support for multiple project types.
Features
Project Management
- Set active projects and get detailed project information
- Create new Xcode projects from templates (iOS, macOS, watchOS, tvOS)
- Add files to Xcode projects with target and group specification
- Parse workspace documents to find associated projects
- List available schemes in projects and workspaces
File Operations
- Read/write files with support for different encodings
- Handle binary files with base64 encoding/decoding
- Search for text content within files using patterns and regex
- Check file existence and get file metadata
- Create directory structures automatically
Build & Testing
- Build projects with customizable options
- Run tests with detailed failure reporting
- Analyze code for potential issues
- Clean build directories
- Archive projects for distribution
CocoaPods Integration
- Initialize CocoaPods in projects
- Install and update pods
- Add and remove pod dependencies
- Execute arbitrary pod commands
Swift Package Manager
- Initialize new Swift packages
- Add and remove package dependencies with various version requirements
- Update packages and resolve dependencies
- Generate documentation for Swift packages using DocC
- Run tests and build Swift packages
iOS Simulator Tools
- List available simulators with detailed information
- Boot and shut down simulators
- Install and launch apps on simulators
- Take screenshots and record videos
- Manage simulator settings and state
Xcode Utilities
- Execute Xcode commands via xcrun
- Compile asset catalogs
- Generate app icon sets from source images
- Trace app performance
- Export and validate archives for App Store submission
- Switch between different Xcode versions
Installation
Prerequisites
- macOS with Xcode 14.0 or higher installed
- Node.js 16 or higher
- npm or yarn
- Swift 5.5+ for Swift Package Manager features
- CocoaPods (optional, for CocoaPods integration)
Setup
Option 1: Automated Setup (Recommended)
Use the included setup script which automates the installation and configuration process:
# Make the script executable
chmod +x setup.sh
# Run the setup script
./setup.sh
What the Setup Script Does:
-
Environment Verification:
- Checks that you’re running on macOS
- Verifies Xcode is installed and accessible
- Confirms Node.js (v16+) and npm are available
- Checks for Ruby installation
- Verifies CocoaPods installation (offers to install if missing)
-
Dependency Installation:
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"xcode": {
"command": "node",
"args": ["/path/to/xcode-mcp-server/dist/index.js"]
}
}
}