随着 AI 编程助手的发展,越来越多的开发工具开始支持通过 MCP(Model Context Protocol) 与 AI Agent 进行深度集成。在 Xcode 26.3 中,可以通过 Gemini CLI 将 Gemini 连接到 Xcode,使 AI 直接读取项目结构、执行编译、运行模拟器甚至自动修复编译错误。本文介绍如何在 Xcode 26.3 中通过 Gemini CLI + MCP 实现 AI 辅助开发,并演示常见的自动化操作。
首先在 Xcode 中开启 MCP 的外部代理访问权限。打开 Settings → Intelligence,启用选项:Allow external agents to use Xcode tools,开启后,Xcode 允许外部 AI Agent(例如 Gemini CLI)调用 Xcode 的构建、运行等工具。
npm install -g @google/gemini-cligemini mcp add xcode-tools xcrun mcpbridge保持 Xcode 项目处于打开状态,然后在项目目录启动 Gemini CLI。当 Gemini 尝试访问 MCP 工具时,Xcode 会弹出授权提示,点击 Allow 即可。授权后,Gemini 就可以通过 MCP 调用 Xcode 的工具链。

在 Gemini CLI 中执行:
/mcp list配置成功之后就可以使用 Xcode 的 MCP 工具。
通过 自然语言 使用 Gemini 操作 Xcode 项目。
Show my Xcode project configurationBuild the Xcode projectRun the app in the iOS simulatorFix the build errors and run againAdd a button that increments a counter in ContentView using SwiftUI.
Then build and run the app.原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。