Test on 50,000+ Real Android and iOS Devices
Live and Automated Real Device Testing on 50,000+ iOS and Android Devices. No Need to Buy or Maintain Device Lab
Xcode Cloud: How to Set Up Workflows, Run Tests and Add Real Devices
Xcode Cloud is Apple's CI/CD for Xcode projects. Set up a workflow, use ci_scripts and env vars, see 2026 pricing, and add real-iPhone XCUITest runs.
Xcode Cloud is Apple's CI/CD service (built into Xcode and App Store Connect) which will build, test, analyze and archive your app on Apple's cloud Macs. It can run tests on simulated devices and can push builds to TestFlight.
An Apple Developer Program membership comes with 25 compute hours per month. Paid plans start at $49.99 for 100 hours.
This covers the first workflow (start conditions and actions), custom build scripts and environment variables, pricing and the primary limit that teams run into (Xcode Cloud test actions run in Simulator). The final section shows how to send each archived build off to a real iPhone via a ci_post_xcodebuild.sh script.
TL;DR
Xcode Cloud is Apple's CI/CD service inside Xcode and App Store Connect. It builds, tests in Simulator, analyzes and archives your app, then ships builds to TestFlight, billed in compute hours with 25 hours a month included in the Apple Developer Program. A post-build script can hand each archive to real iPhones for XCUITest.
Xcode Cloud Workflows, Pricing and Limits
- Xcode Cloud workflow: A workflow combines start conditions (branch, pull request, tag, schedule or manual), actions (build, test, analyze, archive) and post-actions such as TestFlight distribution.
- Xcode Cloud pricing: The Apple Developer Program includes 25 compute hours a month, and paid plans run from 100 hours for $49.99 to 10,000 hours for $3,999.99 a month.
- Xcode Cloud custom scripts: Xcode Cloud runs only
ci_post_clone.sh,ci_pre_xcodebuild.shandci_post_xcodebuild.shfrom theci_scriptsfolder, and a non-zero exit code fails the build. - Xcode Cloud environment variables: Predefined variables such as
CI_XCODEBUILD_ACTIONandCI_WORKFLOWlet scripts branch, and secrets go in custom variables marked Keep value redacted. - Xcode Cloud testing: Xcode Cloud test actions run on simulated devices, and Apple does not support self-hosted device farms. Runs tests on physical iPhones: No.
- Real iPhones with TestMu AI: A
ci_post_xcodebuild.shscript uploads each archived .ipa to TestMu AI and submits an XCUITest run on real iPhones, with video and device logs for review.
What Is Xcode Cloud?
Xcode Cloud is a CI/CD system that requires your code in a Git repository and works with GitHub, GitLab and Bitbucket (cloud and self-managed). Apple's docs list what it does:
- Builds and tests your code automatically on any change you want.
- Tests your app 'on Apple devices in Simulator'.
- Sends results via email, in Xcode and in App Store Connect and can post status to pull requests.
- Distributes builds to internal and external testers via TestFlight and uploads versions for App Review.
Every build runs in what Apple refers to as a "private, isolated and temporary build environment" and Apple states that Xcode Cloud "doesn't store your source code". The build logs, the exported archive and the test result bundles are all available for download for 30 days.
Xcode Cloud covers the Apple side of iOS app testing (compile, unit and UI tests on simulators and delivery). It doesn't give you any physical iPhones, which is where a real device cloud comes in later in this guide.
For a quick visual walkthrough of this concept, watch the video below from TestMu AI.
Subscribe to the TestMu AI YouTube channel for more tutorials on testing and automation.
How Do You Set Up Your Very First Xcode Cloud Workflow?
You configure your first workflow in Xcode (you can also edit workflows in App Store Connect after your first build).
No Mac on the team yet? Our Xcode for Windows guide has all the options.
The steps below are taken from Apple's "Configuring your first Xcode Cloud workflow" guide.
- Enable the archive action in your scheme. Product > Scheme > Edit Scheme, click Build and select the Archive checkbox for the app target. To list the archivable schemes from Terminal:
xcodebuild -project Example.xcodeproj -describeAllArchivableProducts -json - Open the Cloud tab. In the Report navigator, click the Cloud button and then Get Started.
- Select a product. Xcode will then list the apps and frameworks that it finds. One bundle ID maps to one Xcode Cloud product.
- Review the suggested workflow. It's set up by default to build every change to the default branch and every PR that targets it, using the latest released macOS and Xcode and running the archive action. Only click Edit Workflow if the scheme is wrong.
- Grant access to your repository. Click 'Grant Access' and then follow your Git provider's authorization flow.
- Create or confirm the app record. Xcode Cloud requires an App Store Connect app record. You'll need the App Manager, Admin or Account Holder role (or a Developer with the Create Apps permission) in order to create one.
- Start the first build. Select a branch and click Start Build. The logs appear in the Report navigator under each action.
Note: Do we need the same UI tests running on actual iPhones? TestMu AI can run your XCUITest suites on real iPhones and iPads via its device cloud from two uploaded .ipa files, with video and device logs per run. The script later in this guide will show you how to integrate it with Xcode Cloud.
What Actions and Start Conditions Can a Workflow Use?
An Xcode Cloud workflow is a combination of start conditions, actions and post-actions. Each action runs in its own temporary environment so the artifacts of one action are not necessarily available to another (for instance, the result bundle from a test action).
| Workflow part | Options | What runs |
|---|---|---|
| Start conditions | Branch changes, pull request changes, tag changes, schedule, manual | CI_START_CONDITION is one of manual, manual_rebuild, push, pr_open, pr_update, schedule |
| Build action | Any device or any simulator destination | xcodebuild build |
| Test action | Scheme settings or a test plan, one or more simulated destinations, "Required To Pass" or not | xcodebuild build-for-testing, then xcodebuild test-without-building |
| Analyze action | Platform and scheme | xcodebuild analyze |
| Archive action | Deployment Preparation: None, TestFlight (Internal Testing Only), TestFlight and App Store | xcodebuild archive, exported app archive |
| Post-actions | Notifications (email, Slack), TestFlight distribution, upload for App Review | Runs after the actions |
Two settings that save compute hours:
- Auto-cancel Builds is on by default. If you push five changes in five minutes, Xcode Cloud will cancel the first four builds and just build the latest.
- Clean builds bypass the cached derived data. Apple notes that they "significantly" increase build time, though you do need to do a clean build if you're distributing to external TestFlight testers.
How Much Does Xcode Cloud Cost?
Xcode Cloud is priced in compute hours. An hour of compute is defined by Apple as the amount of time spent running a task in the cloud (e.g. building the app, running tests). So five 12-minute tests would add up to one hour.
| Plan | Compute hours per month | Price per month |
|---|---|---|
| Included with Apple Developer Program | 25 | $0 extra |
| Xcode Cloud subscription | 100 | $49.99 |
| Xcode Cloud subscription | 250 | $99.99 |
| Xcode Cloud subscription | 1,000 | $399.99 |
| Xcode Cloud subscription | 10,000 | $3,999.99 |
You can upgrade or downgrade at any time. The Xcode Cloud page doesn't specify what happens if you go over your hours, so it's important to check your usage in App Store Connect prior to a release week. There are additional terms for organizations in the EU (in a separate PDF).
Every additional test destination adds time, so a UI test workflow across many simulators will take the longest. Apple recommends that you run your long UI suites in a separate, less frequent workflow (e.g. once a week).
How Do Custom Build Scripts Work in Xcode Cloud?
Custom build scripts are shell scripts that Xcode Cloud runs at certain points in every action. They reside in a ci_scripts folder alongside your .xcodeproj or .xcworkspace, and only three file names are recognized:
| Script | When it runs | Typical use |
|---|---|---|
ci_post_clone.sh | After Xcode Cloud clones the repository | Install a tool with Homebrew, edit a plist |
ci_pre_xcodebuild.sh | Before xcodebuild | Compile extra dependencies |
ci_post_xcodebuild.sh | After xcodebuild, even if it failed | Upload artifacts to storage or another service |
Rules from Apple's "Writing custom build scripts" page:
- Make each script executable (
chmod +x ci_scripts/ci_post_xcodebuild.sh) and run it with a shebang such as#!/bin/sh. Without both of those things, Xcode Cloud will run it aszsh $filename, and that can fail the build. - A non-zero exit code fails the build. Use
set -eandexit 1on errors. sudocan't grant administrator privileges.- Files that a script creates are deleted and are not passed on to any other scripts, nor are they included in the downloadable artifacts.
- Put anything the scripts read into
ci_scriptsas the source code may not be available in all the phases.
Which Environment Variables Does Xcode Cloud Set?
Xcode Cloud provides a set of predefined variables that your scripts can branch on, and you can of course add your own in the workflow's Environment section.
| Variable | When it's set | What it's for |
|---|---|---|
CI_XCODEBUILD_ACTION | Always | Run a step only for archive or build-for-testing |
CI_XCODEBUILD_EXIT_CODE | After xcodebuild runs | Skip uploads when the build failed |
CI_BUILD_NUMBER | Always | Name the run in another system |
CI_WORKFLOW | Always | Limit a script to one workflow |
CI_PULL_REQUEST_NUMBER | Pull request builds | Run a step only for PRs |
CI_TEST_DESTINATION_DEVICE_TYPE | Test actions | Log which simulated device ran |
CI_RESULT_BUNDLE_PATH | Test actions | Path to the .xcresult bundle |
CI_DEVELOPMENT_SIGNED_APP_PATH | Archive actions | Exported archive signed for development |
CI_APP_STORE_SIGNED_APP_PATH | Archive actions | Exported archive for TestFlight and the App Store |
For API keys, add a custom variable and tick "Keep value redacted" in Xcode (Secret in App Store Connect). Xcode Cloud then shows the value as asterisks in build logs. Never echo a secret any other way.
For test actions, Xcode Cloud passes the variables to the test runner with a TEST_RUNNER_ prefix, which xcodebuild strips so your tests see them by their original name.
Can Xcode Cloud Run Tests on a Real iPhone?
Apple documents Xcode Cloud test actions as being run on simulated devices. The docs talk about testing your app "on Apple devices in Simulator," and the test action variables such as CI_TEST_DESTINATION_DEVICE_TYPE describe "the simulated device you choose".
Self-hosting is not an option either. An Apple engineer replied in May 2024: "We currently do not support users hosting their own device farms using Xcode Cloud".
When the release decision is based on how the app behaves on hardware, the practical setup is to use Xcode Cloud for the build, the unit tests, the simulator UI tests and TestFlight. Each archived build is then sent off to real iPhones on a device cloud.

| Area | Xcode Cloud test action | TestMu AI real device run |
|---|---|---|
| Where tests run | Simulated devices | Real iPhones and iPads (iPhone 8 to iPhone 18 Pro, iOS 14 to 27 per the TestMu AI iOS page) |
| Input | Your scheme or test plan | Two .ipa files: the app and the XCUITest runner |
| Parallel runs | Multiple destinations per action | One entry per device in the device array |
| Evidence | Result bundle (.xcresult), logs | Video, device logs, network logs (toggles in the build request) |
| Status back to CI | Built in | Build status call on the App Testing APIs page; review runs on the Automation dashboard |
How Do You Send Each Xcode Cloud Archive Over to Real iPhones?
Use ci_post_xcodebuild.sh to upload the archived app to TestMu AI and submit an XCUITest run. Xcode Cloud runs this script after every action, so it first checks that we've got a successful archive.
What Apple documents and what you see on your very first run. Apple's variable reference lists three paths that an archive action can set: CI_DEVELOPMENT_SIGNED_APP_PATH (Development signing), CI_AD_HOC_SIGNED_APP_PATH (Ad Hoc) and CI_APP_STORE_SIGNED_APP_PATH (TestFlight and App Store). Apple doesn't say which Deployment Preparation option populates which path or what the file structure is inside.
TestMu AI's .ipa packaging doc will take .ipa files exported via Ad Hoc, Enterprise or Development, so the script will check the Development path first, then the Ad Hoc path, and if neither of those has an .ipa, it will fail the build with a very clear error message. On your very first archive build you can look at the Xcode Cloud log to see which of the paths the script actually used.
Before you start:
- Build the XCUITest runner .ipa once: in Xcode go to Product > Build For > Testing with Any iOS Device (arm64) and put the UI-test runner app Xcode builds (named
<UITestTarget>-Runner.app) into a Payload folder, zip it up and rename it to .ipa as per the packaging doc. The app and the runner must have the same iOS Deployment Target (otherwise the doc says the tests will run locally but not on a real device). Our XCTest tutorial shows how to run the same tests from the command line usingxcodebuild build-for-testingandtest-without-building. - Upload the runner via the XCUITest upload API and keep the
lt://ID that it returns. Upload it again every time the UI tests change:curl -u "$LT_USERNAME:$LT_ACCESS_KEY" --request POST \ "https://manual-api.lambdatest.com/app/uploadFramework" \ --form "appFile=@MyAppUITests-Runner.ipa" \ --form 'type="xcuit-ios"' - In the workflow's Environment section, add:
LT_USERNAMEandLT_ACCESS_KEY(both with "Keep value redacted"),TESTMU_TEST_SUITE_ID(the runner'slt://ID),TESTMU_DEVICE(a device in DeviceName-OSVersion format as per the document) andTESTMU_WORKFLOW(the name of the one workflow that is going to be the one to spend real device minutes). - Add an archive action to that workflow.
#!/bin/sh
# ci_scripts/ci_post_xcodebuild.sh
# Uploads the archived app to TestMu AI and submits an XCUITest run on a real iPhone.
# It fails the Xcode Cloud build if the submission fails. It does not wait for test results.
set -eu
# Workflow variables are set per workflow, so other workflows (PR builds, nightly) skip quietly.
if [ -z "${TESTMU_WORKFLOW:-}" ]; then
echo "Skipping real-device run (TESTMU_WORKFLOW is not set in this workflow)"
exit 0
fi
if [ "${CI_WORKFLOW:-}" != "$TESTMU_WORKFLOW" ] || [ "${CI_XCODEBUILD_ACTION:-}" != "archive" ]; then
echo "Skipping real-device run (workflow ${CI_WORKFLOW:-unset}, action ${CI_XCODEBUILD_ACTION:-unset})"
exit 0
fi
if [ "${CI_XCODEBUILD_EXIT_CODE:-1}" != "0" ]; then
echo "xcodebuild failed, so this build is not sent to real devices."
exit 0
fi
: "${LT_USERNAME:?Add LT_USERNAME as a redacted workflow variable}"
: "${LT_ACCESS_KEY:?Add LT_ACCESS_KEY as a redacted workflow variable}"
: "${TESTMU_TEST_SUITE_ID:?Add TESTMU_TEST_SUITE_ID, the lt:// ID of your uploaded runner}"
: "${TESTMU_DEVICE:?Add TESTMU_DEVICE in DeviceName-OSVersion format}"
# Development export first, then Ad Hoc (both accepted by TestMu AI's .ipa doc)
IPA=""
for DIR in "${CI_DEVELOPMENT_SIGNED_APP_PATH:-}" "${CI_AD_HOC_SIGNED_APP_PATH:-}"; do
if [ -n "$DIR" ] && [ -d "$DIR" ]; then
IPA=$(find "$DIR" -name '*.ipa' | head -n 1)
[ -n "$IPA" ] && break
fi
done
if [ -z "$IPA" ]; then
echo "No development or Ad Hoc .ipa found in this archive's exports."
echo "Check the archive action's Deployment Preparation setting."
exit 1
fi
echo "Using $IPA"
# 1. Upload the app (credentials go in the -u option, never in the URL)
UPLOAD=$(curl --silent --show-error --fail-with-body \
-u "$LT_USERNAME:$LT_ACCESS_KEY" \
--request POST "https://manual-api.lambdatest.com/app/uploadFramework" \
--form "appFile=@$IPA" \
--form 'type="xcuit-ios"')
# The docs give the ID format (lt://...), not the JSON key, so match the value
APP_ID=$(printf '%s' "$UPLOAD" | grep -o 'lt://[A-Za-z0-9]*' | head -n 1 || true)
if [ -z "$APP_ID" ]; then
echo "Upload returned no lt:// app ID"
exit 1
fi
# 2. Submit the XCUITest build (python3 builds the JSON so quotes in names can't break it)
AUTH=$(printf '%s:%s' "$LT_USERNAME" "$LT_ACCESS_KEY" | base64 | tr -d '\n')
BODY=$(APP_ID="$APP_ID" python3 -c 'import json, os; print(json.dumps({
"app": os.environ["APP_ID"],
"testSuite": os.environ["TESTMU_TEST_SUITE_ID"],
"device": [os.environ["TESTMU_DEVICE"]],
"build": "Xcode Cloud " + os.environ.get("CI_BUILD_NUMBER", "manual"),
"video": True, "devicelog": True, "network": False,
"queueTimeout": 10800, "idleTimeout": 150}))')
curl --silent --show-error --fail-with-body \
--request POST "https://mobile-api.lambdatest.com/framework/v1/xcui/build" \
--header "Authorization: Basic $AUTH" \
--header "Content-Type: application/json" \
--data-raw "$BODY"
echo "Real-device XCUITest run submitted for Xcode Cloud build ${CI_BUILD_NUMBER:-manual}"
python3 is available because Apple's temporary build environment includes Python along with the macOS and Xcode tools.
This script does the run. It's not a release gate.
- It fails the Xcode Cloud build (Apple: a non-zero exit code fails the build) if the required variable is missing, if there's no development or Ad Hoc .ipa, if the upload fails, if no
lt://ID comes back or if the build request returns an HTTP error. - It doesn't wait for the test results, so a test that fails on a real iPhone will not fail the Xcode Cloud build. There's no status endpoint in the TestMu AI XCUITest quickstart (the App Testing APIs page documents one). You'll need to review the pass/fail, the video and the device logs on the TestMu AI Automation dashboard under the build name 'Xcode Cloud <build number>' prior to promotion.
- The doc also lists the limits:
geoLocationandtunnelcan't be used together in a single build, XCTestPlan and filters can't be used together, and sharding requires both App Automation and HyperExecute plans.
The Simulator-to-Device Handoff Checklist
Run through these five checks when you set up an Xcode Cloud pipeline for releases:
- Split the workflows out by cost. Fast build + unit tests on every PR. Simulator UI tests on merge or on a schedule. Archive + real device run prior to TestFlight. Then review that run on the TestMu AI Automation dashboard before you promote the build.
- Mark only the 'Required to Pass' tests. A flaky UI test that blocks every PR is a complete time waster and a massive trust burner.
- Keep secrets redacted. All keys in a workflow variable have "Keep value redacted" ticked and scripts never print them.
- Match the deployment targets. The app and the XCUITest runner have the same iOS deployment target and the runner gets re-uploaded whenever the UI tests change.
- Archive what you ship. Download your build artifacts and symbols for App Store builds before the 30-day window expires.
Conclusion
Set up the first workflow with Apple's suggested defaults, then add a separate release workflow with an archive action and the TESTMU_WORKFLOW variable. On its first archive build, check the "Using" line in the Xcode Cloud log to confirm which export path the script picked before you rely on it for a release.
Xcode Cloud tells you the build compiles and the tests pass in Simulator. Before TestFlight, run the same XCUITest runner on the iPhones your users carry and check the results yourself before you promote the build. Start on TestMu AI's real device cloud, upload your two .ipa files, and add the script above to ci_scripts so every archive in your release workflow submits a real-device run with video and device logs.
Running XCUITest before TestFlight? TestMu AI's Real Device Cloud runs your XCUITest builds on real iPhones and iPads from a pool of 50,000+ real devices, with video and device logs for every run.
Was this helpful?
Authors

Shubham Soni
Author · 13 posts
Shubham Soni is a Senior Member of Technical Staff at TestMu AI, building the Real Device Cloud and real-time testing infrastructure. He optimized the WebRTC services that power live testing to sub-100ms latency with adaptive bitrate streaming, led a frontend migration from Angular to React that cut page load time from 5-6 seconds to 1-1.5 seconds, and contributes to the official Device SDK. He led a team of four to build an accessibility testing product covering manual and automated testing and mentored a team of six on a real-time testing product. He brings over eight years of experience and earlier scaled a cloud code platform to 200K+ monthly users. Shubham holds a B.Tech in Computer Science.
Srinivasan Sekar
Reviewer
Srinivasan Sekar is Director of Engineering at TestMu AI, where he leads engineering and open-source initiatives behind the Selenium and Appium automation grid and owns TestMu AI's MCP Server. A committer to Appium and a contributor to Selenium, WebdriverIO, Taiko, and AppiumTestDistribution, he brings over 15 years of experience in quality engineering and open-source technologies. He is the author of the Apress book 'The MCP Standard: A Developer's Guide to Building Universal AI Tools with the Model Context Protocol,' a Certified Kubernetes and Cloud Native Associate, and an international conference speaker. Before TestMu AI he spent over eight years at Thoughtworks as a Principal Consultant and Quality Architect. Srinivasan holds a B.Tech in Information Technology from Anna University.
Xcode Cloud FAQs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance
- Advanced access controls
- Advanced data retention rules
- Advanced Local Testing
- Premium Support options
- Early access to beta features
- Private Slack Channel
- Unlimited Manual Accessibility DevTools Tests




