---
title: iOS XCUITest 云自动化
description: 使用XCUITest为原生iOS应用实现移动iOS应用自动化。确保你的iOS应用程序的最佳质量。在TestingBot设备场的物理iOS设备上进行测试。
source_url:
  html: https://zh.testingbot.com/features/automation/xcuitest
  md: https://zh.testingbot.com/features/automation/xcuitest.md
---

XCUITest 云 
# 在真机iPhone和iPad上运行XCUITest

只需一条 CLI 命令，即可在运行 iOS 12 至 iOS 26 的真实 iPhone 和 iPad 上运行 XCUITest 构建。支持大规模并行处理、视频和日志生成，以及 99.9% 的正常运行时间 SLA。

想了解所有平台？请查看[完整的自动化框架阵容](https://zh.testingbot.com/features)。

[免费开始](https://zh.testingbot.com/users/sign_up) [申请演示](https://testingbot.com/demo)

- **真正的苹果设备:** 100+
- **iOS 版本:** 12 → 26
- **正常运行时间服务级别协议:** 99.9%

被世界上一些最具创新性的公司所信任

 30秒回答 
## 为什么要在 TestingBot 上运行 XCUITest？

真正的iPhone和iPad

使用一系列真实的苹果设备运行，而非 iOS 模拟器。包括苹果发售当天最新款 iPhone，以及大量旧款机型，以实现向下兼容。

替换您内部的苹果实验室

告别堆积灰尘的iPhone、鼓包的电池和令人头疼的MDM问题。TestingBot已在真实设备上进行iOS测试超过5年。

原生 Swift 和 Objective-C

使用 Apple 随 Xcode 提供的 XCUITest 框架。相同的 API，相同的 XCTest 断言，真正的原生性能。

 XCUITest是什么？ 
## XCUITest 耗时 60 秒

 ![XCUITest](https://zh.testingbot.com/assets/environments/svg/ios-383468addf160fa18d0e431f529420739d7f7d1206175f682fead627d2e99a52.svg)

### XCUITest

Apple · built into Xcode · Swift / Objective-C

XCUITest 是苹果官方的 iOS、iPadOS 和 tvOS UI 测试框架。它内置于 Xcode 中，通过 XCTest 在设备上原生运行，并允许您针对应用程序的真实 UI 编写点击、滑动、滚动、谓词和辅助功能查询脚本。

由于 XCUITest 在设备本身上运行，因此测试可以完全访问原生手势、辅助功能标识符和 Apple 官方元素层级结构。无需跨进程桥接，XCUITest 是驱动真实 iPhone 的最精确方法。

- 苹果原生框架，内置于 Xcode 中
- Swift 和 Objective-C 绑定
- 真实的 iPhone、iPad 和 tvOS 系统。无模拟器漂移
- 谓词、辅助功能标识符、原生手势
- XCTest 断言，JUnit XML 输出（用于 CI）

 单行命令行界面 
## 使用一条命令在真实设备上运行 XCUITest

安装 TestingBot CLI，将其指向您的 .ipa 文件和测试包，选择设备即可。上传、功能验证和结果轮询等操作都由系统自动处理。

install the CLI step 1

```bash
# Install the TestingBot CLI
$ npm install -g testingbot-cli

# Authenticate (once) — set your KEY and SECRET
$ export TESTINGBOT_KEY=your-key
$ export TESTINGBOT_SECRET=your-secret

# Build your XCUITest bundle with Xcode (one-off)
$ xcodebuild build-for-testing \
    -scheme MyApp \
    -destination 'generic/platform=iOS'
```

run XCUITest step 2

```bash
# Run XCUITest on a real iPhone — one command
$ testingbot xcuitest MyApp.ipa MyAppUITests-Runner.zip \
    --device "iPhone 16" \
    --version "26" \
    --real-device

# → live results in your TestingBot dashboard
# → JUnit XML, video and logs via REST API
```

有关高级标志、并行运行和 CI 集成，请参阅[TestingBot 上的完整 XCUITest 文档](https://testingbot.com/support/app-automate/xcuitest)。

 购买还是建造 
## TestingBot 与苹果公司内部设备实验室的对比

维护自己的 iPhone 和 iPad 成本很高。设备会损坏，电池会膨胀，iOS 系统更新也每隔几周就要发布一次。以下是托管式 Apple 设备云服务的对比。

| 能力 | 测试机器人 | 苹果公司内部实验室 |
| --- | --- | --- |
| 设备覆盖范围 | 搭载 iOS 12 至 26 系统的真机 iPhone 和 iPad | 仅限于你能购买和购买的商品。 |
| 是时候进行首次测试了 | 只需几分钟，上传您的 .ipa 文件并通过 API 触发即可。 | 数周的配置、MDM、证书、网络共享 |
| 并行扩展 | 最多可同时进行 100 个 XCUITest 会话 | 受您拥有的设备数量限制。 |
| 视频和日志 | 视频、设备日志、屏幕截图和 JUnit XML | 自行实现录制和日志聚合 |
| 可靠性 | 99.9% 正常运行时间 SLA，全天候监控 | 你会更换没电的电池和破损的屏幕。 |
| 安全 | 每次会话之间设备都会被擦除 | 手动清理，遗留状态风险 |
| 支持 | 全天候人工支持和专属客户服务经理 | Stack Overflow 和您自己的日志 |

 能力 
## XCUITest 所需的一切云端功能

除了运行测试之外，TestingBot 还提供了您在 Xcode 中设置的全部 XCUITest 功能，以及仅限云端使用的功能，例如地理位置和网络限速。

- ### [Build & upload](https://testingbot.com/support/app-automate/xcuitest/build-testsuite)

Compile your .ipa and .xctest with Xcode, then push to TestingBot Storage.

- ### [Test reports](https://testingbot.com/support/app-automate/xcuitest/test-reports)

Video, device logs, screenshots and JUnit XML for every run.

- ### [Screen orientation](https://testingbot.com/support/app-automate/xcuitest/change-screen-orientation)

Force portrait or landscape per test, mid-test rotations included.

- ### [Network throttling](https://testingbot.com/support/app-automate/xcuitest/simulate-network-conditions)

Simulate 3G, 4G, lossy WiFi and offline conditions per session.

- ### [Localization & geo](https://testingbot.com/support/app-automate/xcuitest/set-localization-options)

Set device locale, language and GPS coordinates for App Store and back-end checks.

 真正的苹果设备 
## 按需提供 iPhone 和 iPad 设备

通过 XCUItest 框架在 TestingBot 云平台上对真实的 iPhone 和 iPad 进行测试。TestingBot 提供 iOS 12 至 iOS 18 的设备版本。

[查看所有设备](https://testingbot.com/support/app-automate/devices)

 ![Test online on iPhone 17 Pro](https://zh.testingbot.com/assets/devices/160h/44-6b4402c6996d9b1620879bb1123c40a6b36abb064e65dca0a1b3f05286779e9c.webp)

iPhone 17 Pro

 ![Test online on iPhone 17 Pro Max](https://zh.testingbot.com/assets/devices/160h/43-59d7e30684332ed4bf25567cbc09ca942eac46d925ccde8352d3e85812480f7d.webp)

iPhone 17 Pro Max

 ![Test online on iPhone 16 Pro](https://zh.testingbot.com/assets/devices/160h/42-de3704079345026847b739a5b1cf5332595904e54ede66abd988a76fb1e6593c.webp)

iPhone 16 Pro

 ![Test online on iPad (9th generation)](https://zh.testingbot.com/assets/devices/160h/41-70f7d18afde7620063a49a76cbfd088f8b59c742f3a5f4dd4a513dd6ec5c676c.webp)

iPad (9th generation)

 ![Test online on iPhone Air](https://zh.testingbot.com/assets/devices/160h/38-c00a59944eb2e410d375e3f5b39780043f72446bb33b0aea6a26a0c45f309ea1.webp)

iPhone Air

 ![Test online on iPhone 17](https://zh.testingbot.com/assets/devices/160h/36-06478e9d9935ed794bd3ec02c85ad3a8eafe1de3cc11debd15351c1bdc99005b.webp)

iPhone 17

 ![每次运行都会生成视频、屏幕截图和 JUnit XML 文件](https://zh.testingbot.com/assets/features/test-results-315382c39a67ad52167d2a4fd78570c99aea3e0ec386c17e82265851e93cb7b3.png)

 测试报告 
## 每次运行都会生成视频、屏幕截图和 JUnit XML 文件

每次 XCUITest 运行都会生成视频屏幕录像、设备日志、视口屏幕截图以及与所有主流 CI 解析器兼容的 JUnit XML 报告。

从测试中将会话标记为通过或失败，通过我们的[REST API](https://testingbot.com/support/api)获取工件，并将结果发送到 Jira、Slack 或您的 CI 仪表板。

- 每次测试运行均提供全高清视频
- 设备日志、应用日志和崩溃报告
- 按需提供视口屏幕截图
- 适用于 Jenkins、GitHub Actions 和 GitLab CI 的 JUnit XML

 持续集成 
## 几分钟内即可将 XCUITest 集成到您的 CI/CD 流程中

TestingBot 可与所有主流 CI/CD 工具集成。它会在每次构建时触发 XCUITest 运行，并将设备视频和 JUnit 报告流式传输到您的构建仪表板。

 ![Jenkins](https://zh.testingbot.com/assets/integrations/jenkins-e586a1c4af833e4c8d38d7b392a4e84bd193f30cae9cf8c9f198a58ec943a1ff.webp)

### [Jenkins](https://testingbot.com/support/integrations/ci-cd/jenkins)

 ![Bamboo](https://zh.testingbot.com/assets/integrations/bamboo-c8fe09a3cb0b74d6055e3aa6607d77720bfe29ff487b8e3cf825138adf634346.svg)

### [Bamboo](https://testingbot.com/support/integrations/ci-cd/bamboo)

 ![TeamCity](https://zh.testingbot.com/assets/integrations/teamcity-7e75cdb835903a4983ad276c41d95e569ceac5be486e96ec1f955029ce5bb319.svg)

### [TeamCity](https://testingbot.com/support/integrations/ci-cd/teamcity)

 ![CircleCI](https://zh.testingbot.com/assets/integrations/circleci-ede029654ff39b60342e4a5bba8fc9a3a49305cc38bda215b7cf8d07e85e0543.webp)

### [CircleCI](https://testingbot.com/support/integrations/ci-cd/circleci)

 ![GitLab CI](https://zh.testingbot.com/assets/integrations/gitlab-e4c0b6db07d07bc0a400f5606e258f4dc8a51b778e97bbfa51d1d531f3cb049a.webp)

### [GitLab CI](https://testingbot.com/support/integrations/ci-cd/gitlab)

 ![GitHub](https://zh.testingbot.com/assets/integrations/github-actions-8436242ad9e15381f84f1a98a10dddce15611087f121d6305782e211942b7842.webp)

### [GitHub](https://testingbot.com/support/integrations/ci-cd/github-actions)

Spoof device GPS
20+ regions

美国

英国

德国

法国

西班牙

比利时

澳大利亚

中国

日本

 地理位置测试 
## 在 20 多个地区测试您的 iOS 应用

将设备的 GPS 定位欺骗到世界任何地方，并从客户居住的任何国家/地区验证 **定位** 、 **地理定位** 和 **App Store 商店前端规则** 。

 安全设备 
## 真实设备。每次使用后均会清除数据。

每次 XCUITest 测试都会锁定一台真实的 iPhone 或 iPad，仅供您使用。测试结束后，设备将被彻底清除数据，所有已安装的应用将被删除，缓存将被清除，设备将被放回测试池，等待下一位客户使用。

符合 SOC 2 标准和 GDPR 要求，并为企业团队提供 SAML SSO 和审计日志。

- 每次会话使用一台真实设备，绝不共享
- 每次会话之间都会清除数据
- 加密的 .ipa 文件上传，并带有应用级保留控制

[访问 TestingBot 信任中心](https://trust.testingbot.com/)

1. 1

您的 XCUITest 运行会锁定一台真实设备。

您将获得一部崭新的 iPhone 或 iPad，仅供您使用。

2. 2

测试在真正的苹果硬件上原生运行。

真正的传感器、真正的加速度计、真正的 Touch ID 和 Face ID 流程。

3. 3

发布时设备数据已清除

应用已卸载，缓存已清除，账户已注销。已干净地重新投入使用。

 Secure Tunnel 
## 测试与内部后端通信的应用程序

使用我们的[安全隧道](https://testingbot.com/support/tunnel)，以便 XCUITest 运行可以访问私有 API、暂存环境和在本地主机上运行的服务。

端到端加密，无需入站防火墙规则，开箱即用，适用于主流 CI 提供商。

 ![TestingBot secure tunnel for XCUITest](https://zh.testingbot.com/assets/features/tunnel-diagram-poster-8c25e19e6fe4f7276a46a96b31a0ad0e07bb4f5bf98dc192d2b70897cfbb1a26.png)

[阅读更多](https://zh.testingbot.com/support/tunnel)

常问问题
## TestingBot 上的 XCUITest — 常见问题解答

XCUITest是什么？为什么要在TestingBot上运行它？

XCUITest 是苹果公司为 iOS、iPadOS 和 tvOS 开发的原生 UI 测试框架。TestingBot 会在大量真实的 iPhone 和 iPad 设备上运行您的 XCUITest 构建版本，因此您无需自行维护设备、证书和 MDM 系统。只需通过我们的 REST API 上传您的`.ipa`和`.xctest`文件，即可在几秒钟内触发测试运行。

支持哪些iOS版本？

TestingBot 支持从 iOS 12 到 iOS 26 的真机测试，每次苹果发布新版本都会更新。我们不仅提供最新的旗舰 iPhone，还拥有丰富的旧款机型，确保向下兼容。

我需要在Mac电脑上使用TestingBot上的XCUITest吗？

你需要使用 Xcode 来构建 .ipa 和 .xctest 包，但实际的测试运行是在 TestingBot 上进行的。许多团队会在 Mac 运行器上使用 CI 进行构建，然后将构建产物推送到 TestingBot 以在设备上运行。

我可以并行运行 XCUITest 吗？

是的。TestingBot 的计划包括在真实设备上同时进行多达 100 个 XCUITest 会话。每个会话都会锁定一台专用的 iPhone 或 iPad，因此测试之间不会相互干扰。

我可以筛选要运行的测试吗？

是的，我们提供的是真机 iPhone 和 iPad，而非模拟器。每次测试都会锁定一台真机，仅限您使用，设备拥有原生性能，并可访问真实传感器、Touch ID 和 Face ID。测试结束后，设备将被清除数据并重新送回测试池。

如何查看结果？

在 TestingBot 控制面板中实时查看高清视频、屏幕截图和设备日志。可通过[REST API](https://testingbot.com/support/api)以编程方式进行操作。此外，还提供与所有主流 CI 解析器兼容的 JUnit XML 报告。

XCUITest 能否访问我的测试后端？

安装我们的[安全隧道](https://testingbot.com/support/tunnel)后，您的 XCUITest 运行即可访问暂存 API、内部服务和本地主机，而无需任何入站防火墙规则。

该设备云是否符合 GDPR / SOC 2 标准？

TestingBot 符合 GDPR 法规，拥有欧盟数据驻留权，并通过了 ISO 27001 认证和 STAR 1 级认证。设备在会话之间会被清除数据，应用程序上传经过加密，企业版套餐还提供 SAML 单点登录和审计日志功能。

## 准备好开始XCUI测试了吗？

要开始使用，请看我们的[XCUITest](https://testingbot.com/support/app-automate/xcuitest)文档。

[开始免费试用](https://zh.testingbot.com/users/sign_up)

您可能喜欢的资源

[![Automate native iOS Apps with XCUITest](https://zh.testingbot.com/assets/resources/articles/25-bb2ccb531384c461ef792214839e9e8f99a4b08b1293730ceeab67e4a8352563.webp)](https://testingbot.com/resources/articles/automate-native-ios-apps-xcuitest)
### [Automate native iOS Apps with XCUITest](https://testingbot.com/resources/articles/automate-native-ios-apps-xcuitest)

Looking to automate native iOS apps? Read our XCUITest tutorial on how to use code for iOS automation.

[阅读更多](https://testingbot.com/resources/articles/automate-native-ios-apps-xcuitest)

[![Test your website and mobile apps on iOS 18.](https://zh.testingbot.com/assets/blog/2024/ios18.webp)](https://testingbot.com/blog/ios-18-testing)
### [Test your website and mobile apps on iOS 18.](https://testingbot.com/blog/ios-18-testing)

Ready to start testing on iOS 18? Get started today with TestingBot: run automated, visual and manual tests on iOS 18.

[阅读更多](https://testingbot.com/blog/ios-18-testing)
