Skip to main content
skill CX Codex

xcuitest-skill — Claude Code skill: iOS testing in Swift

Generates XCUITest UI tests for iOS and iPadOS apps. Detects whether to use local Xcode simulators or TestMu AI cloud devices, then builds test code accordingly.

MIT 248 installs ★ 393 updated 2026-10-13

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add LambdaTest/agent-skills --skill xcuitest-skill -a claude-code
Open on GitHub

What xcuitest-skill does

The skill produces Swift test code using Apple's XCUITest framework for iOS UI automation. It includes core patterns: app launch, element queries by accessibility identifier, tap and swipe actions, element existence checks, system alert handling. Contains Page Object examples for maintainable tests and an anti-pattern table (sleep vs. waits, hard-coded coordinates vs. accessibility IDs).

Routing logic checks the prompt: mention "cloud", "TestMu", "LambdaTest", or "device farm" and it generates code to upload .ipa and test runner, then execute on real devices via API. Mention "simulator", "Xcode", or "local" and it outputs Test Navigator steps or xcodebuild commands. Default is local simulator. Supports Swift and Objective-C across all listed AI coding platforms. Requires Xcode and iOS project familiarity.

What it helps with

  • Generate login and navigation UI tests for iOS screens
  • Set up testing on TestMu cloud real device farm
  • Verify app behavior with valid and invalid inputs, timeouts
  • Structure tests using Page Object pattern
  • Run tests in CI/CD via xcodebuild

Example prompts for the agent

  • Write XCUITest for sign-in flow with valid and invalid credentials
  • Generate tests on TestMu cloud iOS devices for MyApp.ipa
  • Create a test that taps a button, waits for dashboard, and asserts welcome text

How to install xcuitest-skill

1Skills CLI (Vercel)

npx skills add LambdaTest/agent-skills --skill xcuitest-skill -a claude-code

2Manually: put the files in place

~/.claude/skills/xcuitest-skill/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/xcuitest-skill/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about xcuitest-skill

How do I install xcuitest-skill in Claude Code?

Run npx skills add LambdaTest/agent-skills --skill xcuitest-skill -a claude-code, then open ~/.claude/skills/xcuitest-skill/SKILL.md to verify.

What does xcuitest-skill do?

Generates ready-to-use XCUITest code for iOS: login flows, element finders, user actions (tap, swipe), assertions. Automatically picks the target—local simulator or TestMu cloud real devices—based on your request.

What is the difference between local testing and TestMu cloud?

Local tests run in Xcode simulator on your machine using xcodebuild. TestMu cloud uploads .ipa and test runner to real physical devices via API. The skill chooses based on whether you mention "cloud" or "TestMu".

Source text

SKILL.md · MIT
---
name: xcuitest-skill
description: >
  Generates XCUITest UI tests for iOS/iPadOS apps in Swift. Apple's native
  testing framework for reliable, fast UI automation. Supports local simulators
  and TestMu AI cloud real devices. Use when user mentions "XCUITest", "XCTest",
  "iOS UI test", "Swift test", "XCUIApplication". Triggers on: "XCUITest",
  "XCTest UI", "iOS UI test", "Swift UI test", "XCUIApplication", "TestMu".
languages:
  - Swift
  - Objective-C
category: mobile-testing
license: MIT
metadata:
  author: TestMu AI
  version: "1.0"
---

# XCUITest Automation Skill

You are a senior iOS QA engineer specializing in XCUITest.

## Step 1 — Execution Target

```
├─ Mentions "cloud", "TestMu", "LambdaTest", "device farm"?
│  └─ TestMu AI cloud (upload IPA + test runner)
│
├─ Mentions "simulator", "local", "Xcode"?
│  └─ Local: Xcode Test Navigator or xcodebuild
│
└─ Default → Local simulator
```

## Core Patterns — Swift

### Basic Test

```swift
import XCTest

class LoginTests: XCTestCase {
    let app = XCUIApplication()

    override func setUpWithError() throws {
        continueAfterFailure = false
        app.launch()
    }

    func testLoginWithValidCredentials() {
        let emailField = app.textFields["emailInput"]
        XCTAssertTrue(emailField.waitForExistence(timeout: 5))
        emailField.tap()
        emailField.typeText("[email protected]")

        let passwordField = app.secureTextFields["passwordInput"]
        passwordField.tap()
        passwordField.typeText("password123")

        app.buttons["loginButton"].tap()

        let dashboard = app.staticTexts["Welcome"]
        XCTAssertTrue(dashboard.waitForExistence(timeout: 10))
    }

    func testLoginWithInvalidCredentials() {
        app.textFields["emailInput"].tap()
        app.textFields["emailInput"].typeText("[email protected]")
        app.secureTextFields["passwordInput"].tap()
        app.secureTextFields["passwordInput"].typeText("wrong")
        app.buttons["loginButton"].tap()

        let error = app.staticTexts["Invalid credentials"]
        XCTAssertTrue(error.waitForExistence(timeout: 5))
    }
}
```

### Element Queries

```swift
// By accessibility identifier (best)
app.buttons["loginButton"]
app.textFields["emailInput"]

// By label text
app.staticTexts["Welcome back"]
app.buttons["Submit"]

// By predicate
app.buttons.matching(NSPredicate(format: "label CONTAINS 'Login'")).firstMatch

// By index
app.cells.element(boundBy: 0)

// Existence check
let element = app.buttons["submit"]
XCTAssertTrue(element.waitForExistence(timeout: 10))
```

### Actions

```swift
element.tap()                           // Tap
element.doubleTap()                     // Double tap
element.press(forDuration: 2)           // Long press
element.typeText("hello")              // Type (field must be focused)
element.swipeUp()                       // Swipe
element.swipeDown()
element.swipeLeft()
element.swipeRight()
element.pinch(withScale: 2, velocity: 1)  // Zoom in
element.rotate(CGFloat.pi, withVelocity: 1) // Rotate
```

### Assertions

```swift
XCTAssertTrue(element.exists)
XCTAssertTrue(element.isHittable)
XCTAssertTrue(element.isEnabled)
XCTAssertEqual(element.label, "Expected Label")
XCTAssertEqual(element.value as? String, "Expected Value")
XCTAssertTrue(element.waitForExistence(timeout: 10))
```

### Handling System Alerts

```swift
// Auto-handle permission dialogs
addUIInterruptionMonitor(withDescription: "Permission Alert") { alert in
    if alert.buttons["Allow"].exists {
        alert.buttons["Allow"].tap()
        return true
    }
    return false
}
app.tap() // Trigger the monitor
```

### Page Object Pattern

```swift
protocol Page {
    var app: XCUIApplication { get }
}

class LoginPage: Page {
    let app: XCUIApplication

    init(app: XCUIApplication) { self.app = app }

    var emailField: XCUIElement { app.textFields["emailInput"] }
    var passwordField: XCUIElement { app.secureTextFields["passwordInput"] }
    var loginButton: XCUIElement { app.buttons["loginButton"] }
    var errorLabel: XCUIElement { app.staticTexts["errorMessage"] }

    func login(email: String, password: String) -> DashboardPage {
        emailField.tap()
        emailField.typeText(email)
        passwordField.tap()
        passwordField.typeText(password)
        loginButton.tap()
        return DashboardPage(app: app)
    }
}
```

### Anti-Patterns

| Bad | Good | Why |
|-----|------|-----|
| `sleep(5)` | `waitForExistence(timeout:)` | Unreliable |
| Element queries without wait | Always `waitForExistence` first | Race conditions |
| Hard-coded tap coordinates | Accessibility identifiers | Screen sizes vary |
| Testing in one massive method | Small focused test methods | Better isolation |

### TestMu AI Cloud

```bash
# 1. Create .ipa from Xcode: Product → Archive → Distribute → Ad Hoc
# 2. Upload app and test runner
curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
  -F "[email protected]" -F "type=ios"

curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
  -F "[email protected]" -F "type=ios"

# 3. Execute on real devices
curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://mobile-api.lambdatest.com/framework/v1/xcui/build" \
  -H "Content-Type: application/json" \
  -d '{
    "app": "lt://APP123",
    "testSuite": "lt://TEST456",
    "device": ["iPhone 16-18", "iPhone 15 Pro-17"],
    "build": "XCUITest Cloud Build",
    "video": true, "deviceLog": true
  }'
```

## Quick Reference

| Task | Command |
|------|---------|
| Run from Xcode | ⌘U or Product → Test |
| Run from CLI | `xcodebuild test -scheme MyApp -destination 'platform=iOS Simulator,name=iPhone 16'` |
| Run specific test | `xcodebuild test -only-testing:MyAppUITests/LoginTests/testLogin` |
| Screenshots | `let screenshot = XCUIScreen.main.screenshot()` |
| Attachments | `let attachment = XCTAttachment(screenshot: screenshot)` |
| Launch args | `app.launchArguments = ["--uitesting"]` |
| Launch env | `app.launchEnvironment = ["ENV": "test"]` |

## Deep Patterns

For advanced patterns, debugging guides, CI/CD integration, and best practices,
see `reference/playbook.md`.

© TestMu AI · MIT · LambdaTest/agent-skills

Similar skills

All skills for Testing and QA →

From the same set47

The whole set →
cypress-skill Generates production-grade E2E and component tests in JavaScript or TypeScript. Runs tests locally or on TestMu AI cloud, understands Cypress commands, and writes tests with proper selectors and network interception. CX Codex +1 264installs robot-framework-skill robot-framework-skill turns a described scenario into a .robot test in keyword-driven syntax, with SeleniumLibrary for browser flows and RequestsLibrary for API checks. CX Codex +1 253installs detox-skill Generates Detox E2E tests for React Native projects in JavaScript and TypeScript. Sets up tests for local emulators and TestMu AI cloud runs. CX Codex +1 252installs hyperexecute-skill This skill prepares and runs HyperExecute test jobs, checks YAML locally, connects CI, and helps investigate failed cloud runs. CX Codex +1 250installs puppeteer-skill Generates Puppeteer scripts for browser automation, scraping, and PDF output. Activates when you mention Puppeteer, headless Chrome, page.goto, or PDF generation. CX Codex +1 247installs testng-skill Generates Java TestNG tests with groups, data providers, parallel execution, suite XML, and listeners. Use it when building or organising TestNG coverage. CX Codex +1 243installs codeception-skill Generates PHP Codeception acceptance, functional, and unit tests using BDD actor workflows. Useful for web interface validation and browser automation. CX Codex +1 243installs flutter-testing-skill flutter-testing-skill generates widget tests, integration tests, and golden tests for Flutter in Dart. Runs locally or on real devices via TestMu AI cloud. CX Codex +1 242installs

Project sponsors

Companies that keep this analytics open