AgentSkillsCN

mcp-xcode

使用 Xcode 构建并测试 iOS 应用。当您需要构建项目、运行测试、检查错误、获取构建日志、列出方案、执行干净构建,或归档应用时,可使用此工具。

SKILL.md
--- frontmatter
name: mcp-xcode
description: Build and test iOS apps with Xcode. Use when building projects, running tests, checking errors, getting build logs, listing schemes, clean builds, archiving apps.
allowed-tools: Read, MCP, Bash

Xcode MCP Integration

Table of Contents


1. MCP Tools

xcode_list_schemes

List all schemes in project.

  • Input: None (auto-detect)
  • Output: Scheme list, default scheme
  • Use: First setup, before build

xcode_build

Build project or workspace.

  • Input: scheme (required), configuration (Debug/Release), clean (true/false)
  • Output: Build status, errors, warnings, build time
  • Use: After implementing tasks, before commit

xcode_test

Run unit and UI tests.

  • Input: scheme (required), testPlan (optional), only (specific test)
  • Output: Test results, failed details, coverage
  • Use: After writing tests, before commit

xcode_clean

Clean build folder.

  • Input: scheme (required)
  • Output: Clean status
  • Use: Unclear build errors, after dependency changes

xcode_get_build_settings

Get project build settings.

  • Input: scheme, configuration
  • Output: All build settings
  • Use: Debug build issues

2. Workflows

Setup Project (First Time)

  1. xcode_list_schemes → Save scheme name
  2. xcode_build with scheme, Debug config
  3. Fix errors if any

After Task Implementation

  1. xcode_build with scheme
  2. Success → Continue
  3. Failed → Fix errors → Rebuild

After Phase Completion

  1. xcode_clean
  2. xcode_build with clean: true
  3. xcode_test
  4. All pass → git commit

Pre-Commit

  1. xcode_clean
  2. xcode_build (clean: true)
  3. xcode_test
  4. All pass → commit

3. Error Handling

Common Build Errors

ErrorFix
Syntax errorRead file, fix syntax
Type mismatchCheck types, convert if needed
Missing importAdd import statement
Unresolved identifierCheck declaration, DI

Common Test Errors

ErrorFix
Test timeoutIncrease timeout or check async
Assertion failedCheck logic, update test/code
Missing test targetCheck scheme includes tests

4. Build Configurations

Debug vs Release

SettingDebugRelease
OptimizationNoneAggressive
Debug SymbolsYesNo
Build TimeFastSlow
App SizeLargeSmall

Destinations

  • Simulator: platform=iOS Simulator,name=iPhone 15 Pro
  • Device: platform=iOS,id=[UDID]
  • Generic: generic/platform=iOS

5. Checklist

Each Build

  • Correct scheme name
  • Appropriate configuration
  • Read errors if any
  • Fix errors top to bottom

Each Test Run

  • Build passes first
  • Scheme includes test targets
  • Read failed test details

Pre-Commit

  • Clean build
  • All tests pass
  • No warnings (or acceptable)