XCUI Testing on Real iOS Devices: Quickstart
Run XCUITest, Apple's XCTest-based UI testing framework, on TestMu AI to test your iOS apps across 50,000+ real devices and OS combinations, or on virtual devices. Upload your app and XCUITest test suite as .ipa files, set capabilities such as the device, video and timeouts, trigger the build with one REST API call, and review results on the dashboard.
Developed by Apple, XCUITest is a UI testing framework for iOS applications, commonly used for End-to-End (E2E) testing of app user flows. It is built on top of XCTest, an integrated test framework in Apple's Xcode IDE. TestMu AI lets you perform automated app testing of your iOS apps using XCUITest across 50,000+ real devices and OS combinations. To learn the framework itself, read the XCUITest tutorial.
Prerequisites
- Your TestMu AI Username and Access key.
- Access to an iOS app (.ipa) and an XCUI Test app (.ipa file).
Build the App and Test Suite .ipa Files
You need two .ipa files: your app and the XCUITest test suite (the test runner). Build both in Xcode with Generic iOS Device or Any iOS Device (arm64) as the device target.
App .ipa
- Go to Product > Clean, then Product > Archive.
- Select the archive, click Distribute App and choose an Ad Hoc, Enterprise or Development export. Set App Thinning to None, and clear Rebuild from Bitcode and Include manifest for over-the-air installation.
- Choose your distribution certificate and provisioning profile, then save the exported .ipa file.
Test suite .ipa
- Check that your UI test targets are in Target Membership and are selected for the Test build action of your Xcode build scheme.
- Go to Product > Build For > Testing.
- Find the generated .app file in the Products directory of your Xcode project and package it as an .ipa file:
mkdir Payload
cp -r <YOUR_TEST_RUNNER>.app Payload/
zip -r <YOUR_TEST_SUITE>.ipa Payload
Set the same iOS Deployment Target in Build Settings for the app and the test runner. If they differ, the tests run locally but cannot run on TestMu AI real devices. The full steps, including how to package the app itself from a .app bundle, are in How to Create iOS IPA Files.
Running Your First Test: A Step-by-Step Guide
Step 1: Upload Your Application
To begin testing, upload your iOS application (.ipa file) to TestMu AI's servers. You'll use our REST API for this process.
- Authentication : You'll need your TestMu AI Username and AccessKey. Combine them in the format
Username:AccessKey. - Uploading the App : Use cURL command to send a request to our API. The request should include the path to your application file (appFile).
- Linux / MacOS
- Windows
curl -u "YOUR_LAMBDATEST_USERNAME:YOUR_LAMBDATEST_ACCESS_KEY" --location --request POST 'https://manual-api.lambdatest.com/app/uploadFramework' --form 'appFile=@"<PATH_OF_YOUR_iOS_APP>"' --form 'type="xcuit-ios"'
curl -u "YOUR_LAMBDATEST_USERNAME:YOUR_LAMBDATEST_ACCESS_KEY" -X POST "https://manual-api.lambdatest.com/app/uploadFramework" -F "appFile=@"<PATH_OF_YOUR_iOS_APP>"" -F "type="xcuit-ios""
- Provide the path of your iOS application in the above URL in place of
<PATH_OF_YOUR_iOS_APP> - Response of above cURL will be a JSON object containing the
App URLof the format -lt://APP123456789123456789and will be used in the last step.
Step 2: Upload Your Test Suite
Upload your iOS test suite (.ipa) file to TestMu AI servers using our REST API.
The following sample cURL command shows how to upload a test suite:
- Linux / MacOS
- Windows
curl -u "YOUR_LAMBDATEST_USERNAME:YOUR_LAMBDATEST_ACCESS_KEY" --location --request POST 'https://manual-api.lambdatest.com/app/uploadFramework' --form 'appFile=@"<PATH_OF_YOUR_TEST_SUITE_APP>"' --form 'type="xcuit-ios"'
curl -u "YOUR_LAMBDATEST_USERNAME:YOUR_LAMBDATEST_ACCESS_KEY" --location --request POST "https://manual-api.lambdatest.com/app/uploadFramework" --form "appFile=@"<PATH_OF_YOUR_TEST_SUITE_APP>"" --form "type="xcuit-ios""
- Provide the path of your iOS test suite in the above URL in place of
<PATH_OF_YOUR_TEST_SUITE_APP> - Response of above cURL will be a JSON object containing the
App URLof the format -lt://APP123456789123456789and will be used in the last step.
Step 3: Executing The Test
- You will need base64 encoded authentication in order to execute your XCUITest automation test suite. Enter your
username:accesskeyin Basic Authentication Header Generator to generate your auth token.
Take note of the base64 encoded authentication which needs to be added in the next step.
VerifiedYOUR_LAMBDATEST_USERNAME:YOUR_LAMBDATEST_ACCESS_KEY
- Once you have uploaded your app and test suite, you can execute your test by running the following command:
- On Windows, run the following
curlcommand from Command Prompt (cmd.exe). The command is formatted for the Windows CMD terminal and may require different syntax if executed from PowerShell or another shell. - Before running the command, replace
BASIC_AUTH_TOKEN,APP_ID, andTEST_SUITE_IDwith your actual TestMu AI credentials and resource IDs obtained from the above curl commands.
- Real Device
- Virtual Device
- Linux / MacOS
- Windows
curl --location --request POST 'https://mobile-api.lambdatest.com/framework/v1/xcui/build' \
--header 'Authorization: Basic BASIC_AUTH_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"app": "APP_ID",
"testSuite": "TEST_SUITE_ID",
"device": ["iPhone 11-14"],
"video": true,
"queueTimeout": 10800,
"idleTimeout": 150,
"devicelog": true,
"network": false,
"build": "Proverbial-XCUITest"
}'
curl --location --request POST "https://mobile-api.lambdatest.com/framework/v1/xcui/build" ^
--header "Authorization: Basic BASIC_AUTH_TOKEN" ^
--header "Content-Type: application/json" ^
--data "{\"app\":\"APP_ID\",\"testSuite\":\"TEST_SUITE_ID\",\"device\":[\"iPhone 15-17\"],\"video\":true,\"queueTimeout\":10800,\"idleTimeout\":150,\"devicelog\":true,\"network\":false,\"build\":\"Proverbial-XCUITest\"}"
- Linux / MacOS
- Windows
curl --location --request POST 'https://mobile-api.lambdatest.com/framework/v1/xcui/build' \
--header 'Authorization: Basic BASIC_AUTH_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"app": "APP_ID",
"testSuite": "TEST_SUITE_ID",
"device": ["iPhone 11-14.0"],
"isVirtualDevice": true,
"video": true,
"queueTimeout": 10800,
"idleTimeout": 150,
"devicelog": true,
"network": false,
"build": "Proverbial-XCUITest"
}'
curl --location --request POST "https://mobile-api.lambdatest.com/framework/v1/xcui/build" ^
--header "Authorization: Basic BASIC_AUTH_TOKEN" ^
--header "Content-Type: application/json" ^
--data "{\"app\":\"APP_ID\",\"testSuite\":\"TEST_SUITE_ID\",\"device\":[\"iPhone 15-17.0\"],\"isVirtualDevice\":true,\"video\":true,\"queueTimeout\":10800,\"idleTimeout\":150,\"devicelog\":true,\"network\":false,\"build\":\"Proverbial-XCUITest\"}"
Step 4: View Test Execution
Once you have run your tests, you can view the test execution along with logs. You will be able to see the test cases passing or failing. You can view the same at TestMu AI Automation.
Build Request Capabilities
The build request body takes the capabilities below. The values in the commands above are examples: replace them with your own.
| Capability | Type | What it does |
|---|---|---|
app | String | The app ID returned by the app upload, in the format lt://APP123456789123456789. |
testSuite | String | The test suite ID returned by the test suite upload. |
device | Array | The devices to run on, each in DeviceName-OSVersion format, for example ["iPhone 11-14"]. Pass several devices to run in parallel. |
isVirtualDevice | Boolean | Set to true to run the build on virtual devices instead of real devices. |
video | Boolean | Records a video of every test in the build. |
queueTimeout | Integer | Time in seconds after which the build times out from the queue. |
idleTimeout | Integer | Maximum running time of a test in the build, in seconds. |
devicelog | Boolean | Captures device logs. |
network | Boolean | Captures network logs. |
build | String | The build name shown on the dashboard. |
For geolocation, GPS location, tunnels, Bluetooth, retries, region and the other options, see XCUI Supported Capabilities.
Running Tests in Parallel
You can run tests in parallel on multiple devices by passing the device name in comma separated format in the execute command as show below:
- On Windows, run the following
curlcommand from Command Prompt (cmd.exe). The command is formatted for the Windows CMD terminal and may require different syntax if executed from PowerShell or another shell. - Before running the command, replace
BASIC_AUTH_TOKEN,APP_ID, andTEST_SUITE_IDwith your actual TestMu AI credentials and resource IDs obtained from the above curl commands.
- Real Device
- Virtual Device
- Linux / MacOS
- Windows
curl --location --request POST 'https://mobile-api.lambdatest.com/framework/v1/xcui/build' \
--header 'Authorization: Basic BASIC_AUTH_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"app": "APP_ID",
"testSuite": "TEST_SUITE_ID",
"device": ["iPhone 11-14","iPhone 12 Pro-15","iPhone X-13"],
"video": true,
"queueTimeout": 10800,
"idleTimeout": 150,
"devicelog": true,
"network": false,
"build": "Proverbial-XCUITest"
}'
curl --location --request POST "https://mobile-api.lambdatest.com/framework/v1/xcui/build" ^
--header "Authorization: Basic BASIC_AUTH_TOKEN" ^
--header "Content-Type: application/json" ^
--data "{\"app\":\"APP_ID\",\"testSuite\":\"TEST_SUITE_ID\",\"device\":[\"iPhone 11-14\",\"iPhone 12 Pro-15\",\"iPhone X-13\"],\"video\":true,\"queueTimeout\":10800,\"idleTimeout\":150,\"devicelog\":true,\"network\":false,\"build\":\"Proverbial-XCUITest\"}"
- Linux / MacOS
- Windows
curl --location --request POST 'https://mobile-api.lambdatest.com/framework/v1/xcui/build' \
--header 'Authorization: Basic BASIC_AUTH_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"app": "APP_ID",
"testSuite": "TEST_SUITE_ID",
"device": ["iPhone 11-14.0","iPhone 12 Pro-15.0","iPhone X-13.0"],
"isVirtualDevice": true,
"video": true,
"queueTimeout": 10800,
"idleTimeout": 150,
"devicelog": true,
"network": false,
"build": "Proverbial-XCUITest"
}'
curl --location --request POST "https://mobile-api.lambdatest.com/framework/v1/xcui/build" ^
--header "Authorization: Basic BASIC_AUTH_TOKEN" ^
--header "Content-Type: application/json" ^
--data "{\"app\":\"APP_ID\",\"testSuite\":\"TEST_SUITE_ID\",\"device\":[\"iPhone 11-14.0\",\"iPhone 12 Pro-15.0\",\"iPhone X-13.0\"],\"video\":true,\"queueTimeout\":10800,\"isVirtualDevice\":true,\"idleTimeout\":150,\"devicelog\":true,\"network\":false,\"build\":\"Proverbial-XCUITest\"}"
To run only some of your tests, upload an XCTestPlan file and pass its ID in the xctestplan capability, as described in filter XCUITest runs with an XCTestPlan file. XCTestPlan and filters cannot be used in the same build. To split a large suite into shards that run in parallel on real devices, see Sharding for XCUI, which needs App Automation and HyperExecute plans on your account.
Troubleshooting
If a build does not start or your tests do not run as expected, check these points first:
- Device target: both .ipa files are built with Generic iOS Device or Any iOS Device (arm64) as the device target.
- iOS Deployment Target: the app and the test runner use the same iOS Deployment Target. When they differ, the tests run locally but cannot run on TestMu AI real devices.
- Test targets: your UI test targets are in Target Membership and selected for the Test build action of your scheme.
- IDs and token:
appandtestSuitehold thelt://IDs returned by the two upload calls, andBASIC_AUTH_TOKENis the base64 encoding ofusername:accesskey. - Windows shell: run the build command from Command Prompt (cmd.exe). PowerShell and other shells may need different syntax.
- Geolocation and tunnel:
geoLocationandtunnelare mutually exclusive, so pass only one of them in a build request. - GPS coordinates: latitude must be between -90 and 90 and longitude between -180 and 180, or the build returns an "Invalid GPS location" error.
- App re-signing:
resignApp: falseworks only for apps built for enterprise distribution and is not supported on virtual devices. - XCTestPlan: XCTestPlan and filters cannot be used in the same build.