# Xcode

**Xcode** 是苹果公司的集成开发环境（IDE）和工具套件，用于为其各平台构建、测试和分发软件，包括 iOS、iPadOS、macOS、tvOS、watchOS 和 visionOS。它集成了带智能代码补全的源代码编辑器、苹果设备模拟器、性能分析与调试工具以及构建系统，可在 Mac App Store 获取，测试版则发布于苹果开发者网站。<sup>[1](https://developer.apple.com/documentation/xcode-release-notes)</sup><sup> • </sup><sup>[2](https://developer.apple.com/documentation/xcode?changes=_1)</sup>

| 关键事实 | 详情 |
|---|---|
| 用途 | 为所有苹果平台开发、测试和分发应用的工具套件<sup>[1](https://developer.apple.com/documentation/xcode-release-notes)</sup> |
| 起源 | 源自 Project Builder，最初作为 NeXTSTEP 的一部分开发；2003 年秋更名为 Xcode 1.0<sup>[3](https://media.public.gr/Books-PDF/9781118834336-0954837.pdf)</sup> |
| 核心组织单元 | 项目为构建目标定义默认构建设置；方案定义构建哪些目标、使用哪种配置以及运行哪些测试<sup>[4](https://developer.apple.com/library/archive/featuredarticles/XcodeConcepts/Concept-Projects.html)</sup><sup> • </sup><sup>[5](https://developer.apple.com/library/archive/featuredarticles/XcodeConcepts/Concept-Schemes.html)</sup> |
| 命令行工具 | 随附仅能通过该应用使用的工具，包括 `xcodebuild`、`simctl` 和 `devicectl`<sup>[6](https://developer.apple.com/documentation/xcode/xcode-command-line-tool-reference)</sup> |
| 云服务 | Xcode Cloud，内建于 Xcode 的持续集成与交付服务；苹果开发者计划会员每月包含 25 个计算小时<sup>[7](https://developer.apple.com/xcode-cloud/)</sup> |
| 当前发布线 | Xcode 27 包含 Swift 6.4 以及 iOS 27、iPadOS 27、tvOS 27、watchOS 27、macOS 27 和 visionOS 27 的 SDK，且仅能安装于 Apple 芯片的 Mac<sup>[8](https://developer.apple.com/documentation/xcode-release-notes/xcode-27-release-notes?changes=l_2_3&language=objc)</sup> |
| AI 功能 | Xcode 26.3 新增了基于 Anthropic Claude Agent 和 OpenAI Codex 的代理式编程，并支持通过模型上下文协议访问<sup>[9](https://www.apple.com/newsroom/2026/02/xcode-26-point-3-unlocks-the-power-of-agentic-coding/)</sup> |

## 项目、目标与方案

Xcode 通过项目、目标和方案的层级结构来组织工作。一个项目为其所有目标定义默认构建设置，每个目标可以用自己的设置覆盖这些默认值。<sup>[4](https://developer.apple.com/library/archive/featuredarticles/XcodeConcepts/Concept-Projects.html)</sup> 一个目标对应一个要构建的产品，例如一个应用、框架或测试套件。

一个方案指定应构建哪些目标、构建应采用什么配置以及应运行哪组测试。<sup>[5](https://developer.apple.com/library/archive/featuredarticles/XcodeConcepts/Concept-Schemes.html)</sup> 方案还指定产品启动时使用的可执行环境，当创建新的 iOS 或 macOS 项目时，Xcode 会生成一个涵盖构建、测试和启动操作的默认方案。<sup>[10](https://developer.apple.com/library/archive/documentation/IDEs/Conceptual/xcode_guide-continuous_integration/ConfigureBots.html)</sup> 开发者可自定义方案，以控制构建哪些目标以及构建、运行、测试和性能分析操作的行为方式。<sup>[11](https://developer.apple.com/documentation/xcode/customizing-the-build-schemes-for-a-project?changes=_3)</sup>

## 构建系统

Xcode 构建系统管理将代码和资源文件转化为成品应用的工具。构建开始时，它会分析项目的文件和设置，并汇总要执行的任务集。<sup>[12](https://developer.apple.com/documentation/xcode/build-system?changes=__1)</sup>

开发者通过构建阶段来塑造构建过程，构建阶段是构建系统为某个目标执行的具名任务集。标准阶段包括：依赖，列出必须先构建的其他目标；编译源文件，包含要编译的源文件并允许为每个文件设置编译器标志；链接二进制与库，将编译后的代码与框架和库链接；以及拷贝包资源，将文件放入包的资源目录。一个目标只能包含一个编译源文件阶段和一个链接二进制与库阶段，额外的拷贝文件阶段可将产品放置到 Wrapper、Frameworks、Plugins、XPC Services 或 App Clips 等目的地。Xcode 会自动将 Swift 代码与苹果框架和库链接，因此无需显式列出它们。<sup>[13](https://developer.apple.com/documentation/Xcode/customizing-the-build-phases-of-a-target?changes=_1)</sup>

构建设置也可在纯文本 `.xcconfig` 文件中提供，并为调试和发布构建设置不同的值。<sup>[12](https://developer.apple.com/documentation/xcode/build-system?changes=__1)</sup> 自 Xcode 4 起，默认构建位置为 `~/Library/Developer/Xcode/DerivedData/` 下每个项目的唯一目录。<sup>[14](https://developer.apple.com/library/archive/documentation/Xcode/Conceptual/RN-Xcode-Archive/Chapters/xc4_release_notes.html)</sup>

构建系统在 Xcode 10 引入的新构建系统中获得了并行能力：当一个目标执行链接和代码签名等编译后步骤时，系统会开始编译依赖于它的目标的源文件，从而利用更多可用的处理器核心来提高构建速度。<sup>[15](https://developer.apple.com/documentation/xcode-release-notes/build-system-release-notes-for-xcode-10)</sup>

## 命令行工具与自动化

Xcode 随附一组命令行工具，仅在应用已安装并被设为活动开发者目录时才可用。这些工具包括用于从命令行构建项目和运行测试的 `xcodebuild`、用于管理模拟器的 `simctl`，以及用于与已连接设备交互的 `devicectl`。<sup>[6](https://developer.apple.com/documentation/xcode/xcode-command-line-tool-reference)</sup> 例如，`xcodebuild test -scheme SampleApp` 会运行某个方案的测试，测试由该方案的测试计划选定。<sup>[16](https://developer.apple.com/documentation/xcode/running-tests-and-interpreting-results?changes=_3)</sup>

## Swift 包

Xcode 支持创建、发布和管理 Swift 包，即可复用的 Swift、Objective-C、Objective-C++、C 或 C++ 代码组件，它们捆绑源文件、二进制文件和资源。其包支持构建在开源 Swift Package Manager 项目之上。<sup>[17](https://developer.apple.com/documentation/Xcode/swift-packages)</sup> 包的目标由 Swift Package Manager 编译为模块或测试套件，目标可以作为产品提供给其他包使用。<sup>[18](https://developer.apple.com/documentation/packagedescription/target)</sup> 与应用项目不同，Swift 包不使用 `.xcodeproj` 或 `.xcworkspace` 文件；它们依赖文件夹结构和包清单进行配置。<sup>[19](https://developer.apple.com/documentation/xcode/creating-a-standalone-swift-package-with-xcode?changes=_6%2C_6%2C_6%2C_6)</sup>

对于持续集成，苹果建议提交 `Package.resolved` 文件，该文件位于 `[appName].xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved`，以便构建始终使用预期的依赖版本。<sup>[20](https://developer.apple.com/documentation/xcode/building-swift-packages-or-apps-that-use-them-in-continuous-integration-workflows?v=1.1.1)</sup>

## Xcode Cloud

Xcode Cloud 是内建于 Xcode 的持续集成与交付服务，专为苹果开发者设计。它会构建每一次提交的代码变更，跨设备配置并行运行自动化测试，通过 TestFlight 将构建交付给测试人员，并在 Xcode 和 App Store Connect 网页仪表板中显示构建与测试结果。源代码仅在构建时被访问，数据静态加密，临时构建环境在构建完成后即被销毁。<sup>[7](https://developer.apple.com/xcode-cloud/)</sup>

苹果开发者计划会员每月包含 25 个计算小时。还可购买额外的月度订阅：100 计算小时 49.99 美元，250 计算小时 99.99 美元，1,000 计算小时 399.99 美元，10,000 计算小时 3,999.99 美元。<sup>[7](https://developer.apple.com/xcode-cloud/)</sup> Xcode Cloud 只能构建属于应用项目或工作区的 Swift 包，不能构建独立包。<sup>[21](https://developer.apple.com/documentation/xcode/building-swift-packages-or-swift-playground-app-projects-with-xcode-cloud?changes=l_4&language=objc)</sup>

## 分发与签名

要在 Mac App Store 上分发，应用使用 Apple Distribution 代码签名身份。非应用但使用 Xcode 构建的产品会打包为 Xcode 归档，可从中手动导出分发签名的代码；第三方构建工具需要自己的签名流程。<sup>[22](https://developer.apple.com/documentation/xcode/creating-distribution-signed-code-for-the-mac/)</sup>

## 历史

该工具链源自 Project Builder，这是一个作为 NeXTSTEP 项目一部分开发的 IDE。2003 年秋，苹果以 Xcode 1.0 之名发布了更新增强版本。<sup>[3](https://media.public.gr/Books-PDF/9781118834336-0954837.pdf)</sup> 从 Xcode 3.1 和 iOS 的引入开始，创建项目需要选择平台 SDK。<sup>[23](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html)</sup>

主要的第三方替代 IDE——[JetBrains](https://www.edgepedia.org/zh/jetbrains) 的 AppCode——已停止运营：截至 2022 年 12 月 14 日，JetBrains 停止销售新订阅和续订，活跃订阅获得 2022.3 版本的回落许可证，该版本兼容 macOS 13 和 Xcode 14.2。<sup>[24](https://blog.jetbrains.com/appcode/2022/12/appcode-2022-3-release-and-end-of-sales-and-support/)</sup> 此后，Xcode 之外的 Swift 开发通过编辑器支持得到扩展：官方 Swift 扩展已在 Open VSX Registry 上架，为 VS Code、Cursor、VSCodium、AWS 的 Kiro 和 Google 的 Antigravity 等编辑器带来代码补全、重构、调试和测试浏览器功能，支持 macOS、Linux 和 Windows。<sup>[25](https://www.swift.org/blog/expanding-swift-ide-support/)</sup>

## AI 与代理式编程

Xcode 26 引入了用于编写和编辑 Swift 的编程助手。Xcode 26.3 于 2026 年 2 月作为发布候选版发布，新增了代理式编程，让开发者可以直接在 Xcode 中使用 Anthropic Claude Agent 和 OpenAI Codex 等编程代理来分解任务、基于项目架构做出决策，并以更高的自主性使用内置工具。除这些内置集成外，Xcode 26.3 还通过[模型上下文协议](https://www.edgepedia.org/zh/model-context-protocol)暴露其能力，这是一个开放标准，允许任何兼容的代理或工具与 Xcode 协作。<sup>[9](https://www.apple.com/newsroom/2026/02/xcode-26-point-3-unlocks-the-power-of-agentic-coding/)</sup> Xcode 27 延续了这一方向，让代理能更独立地迭代和优化应用，并使用苹果文档搜索等内置指南和技能。<sup>[26](https://developer.apple.com/documentation/Updates/Xcode)</sup>

## 版本与系统要求

每个 Xcode 版本都搭配一组平台 SDK 和最低 macOS 版本。Xcode 27 及其 27.1 和 27.2 更新要求 macOS Tahoe 26.6 或更高版本，随附 iOS 27.x、tvOS 27.x、watchOS 27.x、visionOS 27.x、macOS 27.x 和 DriverKit 27.x 的 SDK，支持部署目标回溯至 iOS 15、tvOS 15、watchOS 9、visionOS 1 和 macOS 12，并以 Swift 6.4 在 Swift 6、5、4.2 和 4 语言模式下编译。<sup>[27](https://developer.apple.com/xcode/system-requirements)</sup> Xcode 27 仅在 Apple 芯片的 Mac 上安装和运行。<sup>[8](https://developer.apple.com/documentation/xcode-release-notes/xcode-27-release-notes?changes=l_2_3&language=objc)</sup> 为 visionOS 开发需要搭载 Apple 芯片的 Mac。<sup>[27](https://developer.apple.com/xcode/system-requirements)</sup>

## References

1. [Xcode Release Notes, Apple Developer Documentation](https://developer.apple.com/documentation/xcode-release-notes)
2. [Xcode, Apple Developer Documentation](https://developer.apple.com/documentation/xcode?changes=_1)
3. [Xcode history chapter, Wiley companion PDF (Project Builder and Xcode 1.0)](https://media.public.gr/Books-PDF/9781118834336-0954837.pdf)
4. [Xcode Project, Xcode Concepts, Apple Developer Library](https://developer.apple.com/library/archive/featuredarticles/XcodeConcepts/Concept-Projects.html)
5. [Xcode Scheme, Xcode Concepts, Apple Developer Library](https://developer.apple.com/library/archive/featuredarticles/XcodeConcepts/Concept-Schemes.html)
6. [Xcode command-line tool reference, Apple Developer Documentation](https://developer.apple.com/documentation/xcode/xcode-command-line-tool-reference)
7. [Xcode Cloud Overview, Apple Developer](https://developer.apple.com/xcode-cloud/)
8. [Xcode 27 Release Notes, Apple Developer Documentation](https://developer.apple.com/documentation/xcode-release-notes/xcode-27-release-notes?changes=l_2_3&language=objc)
9. [Xcode 26.3 unlocks the power of agentic coding, Apple Newsroom](https://www.apple.com/newsroom/2026/02/xcode-26-point-3-unlocks-the-power-of-agentic-coding/)
10. [Xcode Server and Continuous Integration Guide: Configure Bots, Apple Developer Library](https://developer.apple.com/library/archive/documentation/IDEs/Conceptual/xcode_guide-continuous_integration/ConfigureBots.html)
11. [Customizing the build schemes for a project, Apple Developer Documentation](https://developer.apple.com/documentation/xcode/customizing-the-build-schemes-for-a-project?changes=_3)
12. [Build system, Apple Developer Documentation](https://developer.apple.com/documentation/xcode/build-system?changes=__1)
13. [Customizing the build phases of a target, Apple Developer Documentation](https://developer.apple.com/documentation/Xcode/customizing-the-build-phases-of-a-target?changes=_1)
14. [Xcode 4 Release Notes, Apple Developer Library](https://developer.apple.com/library/archive/documentation/Xcode/Conceptual/RN-Xcode-Archive/Chapters/xc4_release_notes.html)
15. [Build System Release Notes for Xcode 10, Apple Developer Documentation](https://developer.apple.com/documentation/xcode-release-notes/build-system-release-notes-for-xcode-10)
16. [Running tests and interpreting results, Apple Developer Documentation](https://developer.apple.com/documentation/xcode/running-tests-and-interpreting-results?changes=_3)
17. [Swift packages, Apple Developer Documentation](https://developer.apple.com/documentation/Xcode/swift-packages)
18. [Target, PackageDescription, Apple Developer Documentation](https://developer.apple.com/documentation/packagedescription/target)
19. [Creating a standalone Swift package with Xcode, Apple Developer Documentation](https://developer.apple.com/documentation/xcode/creating-a-standalone-swift-package-with-xcode?changes=_6%2C_6%2C_6%2C_6)
20. [Building Swift packages or apps that use them in continuous integration workflows, Apple Developer Documentation](https://developer.apple.com/documentation/xcode/building-swift-packages-or-apps-that-use-them-in-continuous-integration-workflows?v=1.1.1)
21. [Building Swift packages and Swift Playgrounds app projects with Xcode Cloud, Apple Developer Documentation](https://developer.apple.com/documentation/xcode/building-swift-packages-or-swift-playground-app-projects-with-xcode-cloud?changes=l_4&language=objc)
22. [Creating distribution-signed code for macOS, Apple Developer Documentation](https://developer.apple.com/documentation/xcode/creating-distribution-signed-code-for-the-mac/)
23. [What Is Cocoa?, Apple Developer Library](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html)
24. [AppCode 2022.3 Release and End of Sales and Support, The JetBrains Blog](https://blog.jetbrains.com/appcode/2022/12/appcode-2022-3-release-and-end-of-sales-and-support/)
25. [Expanding Swift's IDE Support, Swift.org](https://www.swift.org/blog/expanding-swift-ide-support/)
26. [Xcode updates, Apple Developer Documentation](https://developer.apple.com/documentation/Updates/Xcode)
27. [SDK and system requirements, Xcode, Apple Developer](https://developer.apple.com/xcode/system-requirements)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Development tools and collaboration infrastructure › Build, deployment, and development tooling

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/xcode

English original: https://www.edgepedia.org/xcode
