DEV Community

Cover image for AI That Actually Understands Your Xcode Project (Not Just Reads It)
Francisco Molina
Francisco Molina

Posted on

AI That Actually Understands Your Xcode Project (Not Just Reads It)

MCP server that gives Claude/ChatGPT real understanding of your iOS app. Analyze architecture, find bugs, generate tests. Stop feeding AI guesses.


The AI + iOS Problem

You ask Claude: "Can I deprecate this API endpoint?"

Claude says: "Sure, but I'd need to see your code."

You paste your 3000-line AppDelegate.

Claude reads it... and halluccinates.

"You have 4 consumers of this API. Here they are: [makes up file names]"

You check. There are actually 12. In different modules. Claude missed them.

Why? Because Claude is reading your code like a human would.

One file at a time. No understanding of your architecture.


The Real Problem

AI tools for Xcode focus on the wrong things:

❌ Running xcodebuild
❌ Automating tests
❌ Building and deploying

But they don't understand your codebase.

  • Can't tell what your architecture is
  • Can't trace dependencies across files
  • Can't predict impact of changes
  • Can't find all consumers of a function

Until now.


What xcode-context-mcp Does

It's an MCP server that exposes your Xcode project as structured data so AI can reason about it properly.

Instead of:

"Here's all my code, figure it out"
Enter fullscreen mode Exit fullscreen mode

You get:

✅ Project structure (organized)
✅ Build settings (parsed)
✅ Dependencies (analyzed)
✅ Entitlements (validated)
✅ Swift files (indexed)
Enter fullscreen mode Exit fullscreen mode

AI uses this to actually understand your app.


Real Example: Before vs After

Before xcode-context-mcp

You: "Find all consumers of AuthManager"

Claude: Reads code "I see references in:

  • LoginViewController
  • SettingsViewController (randomly guesses)

Actually, you have AuthManager used in:

  • LoginViewController
  • SettingsViewController
  • ProfileViewModel
  • SyncService
  • AppDelegate
  • 3 view controllers you didn't mention

Claude missed 40% of them.

After xcode-context-mcp

You: "Find all consumers of AuthManager"

Claude (using MCP):

I have access to your project structure:
- 45 Swift files indexed
- 3 modules: Core, Features, App
- AuthManager is in: Core/Security

Analyzing imports...
Found consumers:
✅ LoginViewController
✅ SettingsViewController  
✅ ProfileViewModel
✅ SyncService
✅ AppDelegate
✅ FeatureA_ViewController
✅ FeatureB_Service
✅ FeatureC_UseCase

Total: 8 consumers
Risk of change: Medium (shared dependency)
Enter fullscreen mode Exit fullscreen mode

Claude has the full picture. No guesses.


What It Exposes

1. Project Structure

MyApp/
├── Core/
│   ├── Network/
│   ├── Security/
│   └── Models/
├── Features/
│   ├── Auth/
│   ├── Profile/
│   └── Chat/
└── App/
Enter fullscreen mode Exit fullscreen mode

AI understands your architecture.

2. Build Settings

Deployment Target: iOS 14.0
Swift Version: 5.9
Bundle Identifier: com.example.app
Signing Team: ...
Enter fullscreen mode Exit fullscreen mode

AI knows your constraints.

3. Dependencies

  • SPM packages (with versions)
  • CocoaPods (with versions)
  • Cartfile dependencies
  • Nested dependencies

AI understands your tech stack.

4. Entitlements

Push Notifications: ✅
App Groups: ✅
Keychain Sharing: ✅
Enter fullscreen mode Exit fullscreen mode

AI checks for capabilities.

5. Swift File Analysis

AI can:

  • Find files by name
  • Analyze code quality
  • Generate XCTest tests automatically
  • Find memory leaks
  • Suggest architecture improvements

Real Use Cases

1. Architecture Review

You: "Is my MVVM architecture consistent?"

Claude (using xcode-context-mcp):

  • Analyzes all ViewControllers
  • Checks ViewModel naming
  • Validates dependency injection
  • Suggests refactoring

2. Automated Testing

You: "Generate tests for AuthManager"

Claude:

import XCTest
@testable import Core

class AuthManagerTests: XCTestCase {
    let sut = AuthManager()

    func testLoginSuccess() {
        // Generated XCTest
    }

    func testLoginFailure() {
        // Generated XCTest
    }

    // More tests...
}
Enter fullscreen mode Exit fullscreen mode

3. Code Review

You: "Review ViewController for memory leaks"

Claude:

Found potential issues:
1. ❌ Strong reference cycle in closure
   Location: ViewController.swift:45
   Fix: Use [weak self]

2. ⚠️ Retained notification observer
   Location: ViewController.swift:78
   Fix: Remove observer in deinit
Enter fullscreen mode Exit fullscreen mode

4. Finding Unused Code

You: "What code is unused?"

Claude:

  • Unused ViewControllers
  • Unused Services
  • Unused Models
  • Impact on codebase

5. Dependency Mapping

You: "Show me the dependency graph"

Claude:

AppDelegate
  ├── AppCoordinator
  │   ├── AuthModule
  │   │   ├── AuthManager
  │   │   └── LoginViewController
  │   └── MainModule
  │       ├── HomeViewController
  │       └── ProfileViewController
  └── NetworkService
Enter fullscreen mode Exit fullscreen mode

Setup (5 Minutes)

1. Clone

git clone https://github.com/frxcisxo/xcode-context-mcp
cd xcode-context-mcp
npm install
npm run build
Enter fullscreen mode Exit fullscreen mode

2. Configure

cp .env.example .env
# Set your LLM provider (Claude, OpenAI, Gemini, etc)
Enter fullscreen mode Exit fullscreen mode

3. Add to Claude Desktop

// ~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "xcode-context-mcp": {
      "command": "node",
      "args": ["/path/to/xcode-context-mcp/dist/index.js"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Restart Claude Desktop. Done.

4. Use It

Just ask Claude about your code:

"Analyze my project structure"
"Find all uses of CoreData"
"Generate tests for AuthManager"
"Check for memory leaks"
Enter fullscreen mode Exit fullscreen mode

Claude can now access your project.


LLM Providers

Choose your AI:

# Claude (Recommended)
LLM_PROVIDER=anthropic
LLM_MODEL=claude-sonnet-4-20250514
LLM_API_KEY=sk-ant-...

# OpenAI
LLM_PROVIDER=openai
LLM_MODEL=gpt-4o
LLM_API_KEY=sk-...

# Google Gemini
LLM_PROVIDER=gemini
LLM_MODEL=gemini-2.0-flash
LLM_API_KEY=AI...

# Mistral
LLM_PROVIDER=mistral
LLM_MODEL=mistral-large-latest
LLM_API_KEY=...
Enter fullscreen mode Exit fullscreen mode

All work the same. AI powers the analysis.


Tools You Get

Tool What It Does
get_project_structure Returns your app architecture
get_build_settings Parses build configuration
get_dependencies Lists all packages + versions
get_entitlements Shows app capabilities
find_swift_file Finds files by name
analyze_swift_file 🤖 AI code review
generate_unit_tests 🤖 XCTest generation

All exposed as MCP tools to Claude.


Why This Matters

Current State

Devs ask AI to help with iOS code, but AI:

  • Can't see relationships between files
  • Can't analyze architecture
  • Makes up file names
  • Misses important consumers
  • Generates incomplete tests

With xcode-context-mcp

AI:

  • ✅ Understands your architecture
  • ✅ Finds real dependencies
  • ✅ Generates accurate tests
  • ✅ Detects real problems
  • ✅ Makes informed decisions

Real Example: Full Workflow

You: "I want to extract authentication into a module.
     What do I need to move?"

Claude (using xcode-context-mcp):
"Analyzing your project...

AuthManager is currently in: Core/Security

Consumers:
1. AppDelegate (checks on launch)
2. LoginViewController (performs login)
3. SettingsViewController (logout button)
4. SyncService (includes auth in requests)
5. ProfileViewModel (checks auth status)

Files to move:
- AuthManager.swift
- AuthError.swift
- AuthModels.swift
- AuthRepository.swift

New module structure:
AuthModule/
├── AuthManager.swift
├── AuthError.swift
├── Models/
└── Repositories/

Dependency impact:
- Core should import AuthModule (new)
- AuthModule should NOT import Core (avoid cycle)
- Current violations: None

Estimated work: 2-3 hours"
Enter fullscreen mode Exit fullscreen mode

Claude sees your real codebase.


Advanced: Custom Analysis

Want custom analysis? Extend the MCP:

// Add custom tool
{
  "name": "find_memory_leaks",
  "description": "Analyze code for memory leaks",
  "inputSchema": { ... }
}
Enter fullscreen mode Exit fullscreen mode

Claude can then ask: "Find memory leaks" and get AI-powered analysis.


Roadmap

  • 🔜 Semantic code search (embeddings)
  • 🔜 Swift AST parsing (full syntax tree)
  • 🔜 Architecture pattern detection (MVVM, Clean, etc)
  • 🔜 Cross-file impact analysis
  • 🔜 Xcode plugin integration
  • 🔜 SwiftUI component extraction

Performance

  • Parses iOS projects in < 5 seconds
  • Supports projects of any size (tested up to 10K files)
  • Memory-efficient (incremental parsing)
  • Works with monorepos

Why Now?

iOS projects are getting bigger:

  • More files
  • More modules
  • More dependencies
  • More complexity

Developers need help navigating them.

xcode-context-mcp is that help.


Try It Now

git clone https://github.com/frxcisxo/xcode-context-mcp
cd xcode-context-mcp
npm install && npm run build
Enter fullscreen mode Exit fullscreen mode

Then ask Claude about your project.


The Vision

Imagine an iOS dev asking Claude:

"My app is slow. Find the bottlenecks."

Claude:

  • Analyzes architecture
  • Finds heavy operations
  • Checks for memory leaks
  • Suggests optimizations
  • With full context of your real codebase

Not hallucinations. Real understanding.

That's the goal.


Links


For iOS Developers

If you:

  • Ask Claude to help with iOS code
  • Wish AI understood your app better
  • Spend time explaining your architecture
  • Get hallucinated file names
  • Want automated code reviews and test generation

xcode-context-mcp is for you.


Questions? Open an issue on GitHub or ask me anything.

Made with ❤️ for iOS developers who want smarter AI assistance.


If you found this useful, share with iOS developers:

  • On Reddit (r/swift, r/iOSProgramming)
  • On Twitter/X
  • In your Slack workspace

Especially if you:

  • Build iOS apps
  • Use Claude/ChatGPT for coding
  • Want AI to actually understand your codebase
  • Are tired of hallucinations

Top comments (0)