---
title: 'Build for Testing: The App and the Test Runner | TestingBot'
description: So far Xcode has built and run the tests in one step. To run the same
  tests somewhere else (another simulator, a CI machine, real iPhones in a device
  cloud)…
source_url:
  html: https://testingbot.com/resources/courses/xcuitest/build-for-testing
  md: https://testingbot.com/resources/courses/xcuitest/build-for-testing.md
---

Course

[XCUITest Tutorial: iOS UI Testing in Swift](https://testingbot.com/resources/courses/xcuitest)

Chapter 8 of 11

1. [1 XCUITest Tutorial: iOS UI Test Automation in Swift](https://testingbot.com/resources/courses/xcuitest)
2. [2 Add a UI Test Target and Run Your First Test](https://testingbot.com/resources/courses/xcuitest/add-a-ui-test-target)
3. [3 Element Queries and Accessibility Identifiers](https://testingbot.com/resources/courses/xcuitest/queries-and-accessibility-identifiers)
4. [4 Interactions and Assertions](https://testingbot.com/resources/courses/xcuitest/interactions-and-assertions)
5. [5 Waiting Without sleep(): waitForExistence and Predicates](https://testingbot.com/resources/courses/xcuitest/waiting-without-sleep)
6. [6 Screen Objects in Swift](https://testingbot.com/resources/courses/xcuitest/screen-objects)
7. [7 Launch Arguments and Environment: Control App State](https://testingbot.com/resources/courses/xcuitest/launch-arguments-and-environment)
8. [8 Build for Testing: The App and the Test Runner](https://testingbot.com/resources/courses/xcuitest/build-for-testing)
9. [9 Run XCUITest on Real iPhones with TestingBot](https://testingbot.com/resources/courses/xcuitest/run-on-testingbot)
10. [10 XCUITest in CI with GitHub Actions](https://testingbot.com/resources/courses/xcuitest/ci-github-actions)
11. [11 XCUITest Knowledge Check](https://testingbot.com/resources/courses/xcuitest/knowledge-check)

[Exit course](https://testingbot.com/resources/courses)

 Chapter 8 of 11 Intermediate 5 min read 2 quick checks Updated Nov 2026 

# Build for Testing: The App and the Test Runner
On this page
1. [build-for-testing and test-without-building](https://testingbot.com#build-for-testing-and-test-without-building)
2. [Simulator builds and device builds](https://testingbot.com#simulator-builds-and-device-builds)
3. [Signing](https://testingbot.com#signing)
4. [Package the two files](https://testingbot.com#package-the-two-files)

So far Xcode has built and run the tests in one step. To run the same tests somewhere else (another simulator, a CI machine, real iPhones in a device cloud) you split that step in two: **build for testing** once, then **run without building** wherever the tests should execute. This chapter shows what the build produces, how simulator and device builds differ, and how to package the two files a device cloud needs.

## build-for-testing and test-without-building[#](https://testingbot.com#build-for-testing-and-test-without-building)

```bash
xcodebuild build-for-testing \
  -project Tasks.xcodeproj -scheme Tasks \
  -destination 'generic/platform=iOS Simulator' \
  -derivedDataPath build-sim
```

`generic/platform=iOS Simulator` builds for "any simulator" instead of one particular device, and `-derivedDataPath` puts the output in a folder you choose instead of somewhere under `~/Library/Developer/Xcode/DerivedData`. The products:

```
build-sim/Build/Products/
  Debug-iphonesimulator/
    Tasks.app
    TasksUITests-Runner.app
  Tasks_iphonesimulator26.4-arm64-x86_64.xctestrun
```

Three things, and you need all of them:

- **`Tasks.app`** , the app under test.
- **`TasksUITests-Runner.app`** , the test runner. It is a small app generated by Xcode that contains your compiled tests as a plug-in (`PlugIns/TasksUITests.xctest`). This is the process that drives `Tasks.app`.
- **The `.xctestrun` file** , a property list that describes which test bundles to run against which app, with which launch arguments and environment. It is what makes running without building possible.

Run the tests from that build, without compiling anything:

```bash
xcodebuild test-without-building \
  -xctestrun build-sim/Build/Products/Tasks_iphonesimulator26.4-arm64-x86_64.xctestrun \
  -destination 'platform=iOS Simulator,name=iPhone 17,OS=26.4.1' \
  -only-testing:TasksUITests/LaunchTests
```

```
Test Case '-[TasksUITests.LaunchTests testLoginScreenAppears]' passed (3.501 seconds).
**TEST EXECUTE SUCCEEDED**
```

The split pays off in CI: build once, then run the same products on several simulators in parallel jobs, or archive them and run them later. Chapter 9 uses it.

You changed one assertion in a UI test and ran `xcodebuild test-without-building` with the existing `.xctestrun`. The old assertion still fails. Why?

 `.xctestrun` files cache test results The tests are compiled into the runner; without a new `build-for-testing` the old code runs `test-without-building` only runs unit tests

Your Swift tests are compiled into `TasksUITests.xctest` inside the runner app. "Without building" means exactly that, so any change to the app or the tests needs a new build-for-testing first.

## Simulator builds and device builds[#](https://testingbot.com#simulator-builds-and-device-builds)

Simulators on a Mac run simulator binaries; iPhones run device binaries. A build for one does not install on the other, so for real devices you build again with a device destination:

```bash
xcodebuild build-for-testing \
  -project Tasks.xcodeproj -scheme Tasks \
  -destination 'generic/platform=iOS' \
  -derivedDataPath build-device \
  CODE_SIGNING_ALLOWED=NO
```

```
**TEST BUILD SUCCEEDED**
```

The products are in `build-device/Build/Products/Debug-iphoneos/` (note `iphoneos`, not `iphonesimulator`): the same `Tasks.app` and `TasksUITests-Runner.app`, compiled for the device.

## Signing[#](https://testingbot.com#signing)

iOS only installs signed apps on a device. Which signature you need depends on where the tests will run:

- **Your own iPhone, from Xcode or `xcodebuild test`** : sign with your development team (Signing & Capabilities in Xcode, or `DEVELOPMENT_TEAM=...` plus `-allowProvisioningUpdates` on the command line). The device must be registered in that team's provisioning profile.
- **A device cloud** : the devices belong to the provider, not to your team, so a development profile from your account does not list them. TestingBot re-signs the uploaded app and test runner for its own devices. The course's build above used `CODE_SIGNING_ALLOWED=NO`, which produces unsigned bundles (`codesign -dv` reports "code object is not signed at all"), and that upload installed and ran on TestingBot's iPhones in chapter 8. If your pipeline already produces a development- or ad hoc-signed build, uploading that one is the conventional route the [XCUITest documentation](https://testingbot.com/support/app-automate/xcuitest) describes.

Turning signing off is also handy in CI: the build machine does not need your certificates at all.

## Package the two files[#](https://testingbot.com#package-the-two-files)

A device cloud wants the app as an `.ipa` and the runner as a `.zip`. An `.ipa` is a zip file with the app inside a folder called `Payload`:

```bash
cd build-device/Build/Products/Debug-iphoneos
mkdir Payload
cp -R Tasks.app Payload/
zip -qry ../../../../Tasks.ipa Payload
rm -rf Payload
zip -qry --symlinks ../../../../TasksUITests.zip TasksUITests-Runner.app
```

`--symlinks` (as in the TestingBot documentation) stores any symbolic links inside the bundle as links instead of copying what they point to. The result for this course: `Tasks.ipa` at 91 KB and `TasksUITests.zip` at 5.9 MB (most of that is the XCTest frameworks the runner carries). Check the top of each archive before uploading:

```
$ unzip -l Tasks.ipa
  Payload/
  Payload/Tasks.app/
  ...
$ unzip -l TasksUITests.zip
  TasksUITests-Runner.app/
  TasksUITests-Runner.app/PlugIns/
  ...
```

Common mistakes, each of which makes the upload fail to install:

- **Zipping `Debug-iphonesimulator`** products for a real device.
- **Zipping the folder that contains the runner** instead of the runner itself, so the archive starts with `Debug-iphoneos/`.
- **Uploading `TasksUITests.xctest`** on its own. The cloud needs the whole `-Runner.app` that hosts it.
- **Building the Release configuration** when the app's test hooks are inside `#if DEBUG` (chapter 6).

The [Build an XCUITest suite](https://testingbot.com/support/app-automate/xcuitest/build-testsuite) page shows the same steps from the Xcode menus (Product \> Build For \> Testing, then Show Build Folder in Finder) if you prefer clicking.

Which pair of files does a real-device XCUITest run in the cloud need?

 The project's `.xcodeproj` and the test sources `Tasks.app` and `TasksUITests.xctest` from `Debug-iphonesimulator` The `.xcresult` bundle from a local run The app as an `.ipa` and `TasksUITests-Runner.app` zipped, both built for `iphoneos`

The cloud installs compiled bundles; it does not build source. They must be device builds, and the tests travel inside the runner app, not as a bare `.xctest`. An `.xcresult` holds results, not something to run.

Next: uploading those two files and running them on real iPhones.

[Previous · Chapter 7 Launch Arguments and Environment: Control App State](https://testingbot.com/resources/courses/xcuitest/launch-arguments-and-environment) [Next · Chapter 9 Run XCUITest on Real iPhones with TestingBot](https://testingbot.com/resources/courses/xcuitest/run-on-testingbot)

On this page

1. [build-for-testing and test-without-building](https://testingbot.com#build-for-testing-and-test-without-building)
2. [Simulator builds and device builds](https://testingbot.com#simulator-builds-and-device-builds)
3. [Signing](https://testingbot.com#signing)
4. [Package the two files](https://testingbot.com#package-the-two-files)

Certification

Earn the free, resume-worthy TestingBot XCUITest Certification for this course.

[How it works](https://testingbot.com/resources/courses/xcuitest/certification)
