---
# System prepended metadata

title: CLI Test iOS UI with Appium on Real Devices

---

# CLI Test iOS UI with Appium on Real Devices

Tools:
1. xcode
2. appium
3. python
4. idevice_id

## Steps
1. Get [WebDriverAgent.xcodeproj](https://github.com/facebookarchive/WebDriverAgent) and follow the tutorial to setup (change **WebDriverAgentLib** and **WebDriverAgentRunner** Product Bundle Identifier, Team Development)
3. Install Appium with npm
```npm intsall -g appium```
4. Install python and requirement lib
```pip install Appium-Python-Client```

## Command
1. xcodebuild
> only run test

- Run on Real Devices
```
xcodebuild test \
-destination 'id=$device_id' \
-project /path/to/WebDriverAgent.xcodeproj \
-sdk $SDK 
-scheme WebDriverAgentRunner
```

Example:
```
xcodebuild test \
-destination 'id=fb88b2c1267729e5998fbd47ae814a198e533a45' \
-project /Users/jackytan/.nvm/versions/node/v11.10.0/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj \
-sdk iphoneos12.2 \
-scheme WebDriverAgentRunner
```

- Run on Simulator
```
xcodebuild test \
-project /path/to/WebDriverAgent.xcodeproj \
-sdk $SDK \
-scheme WebDriverAgentRunner \
-destination $DESTINATION
```

Support:
- Get Device UDID
```idevice_id -ls```

- $SDK
```xcodebuild -showsdks```

- $DESTINATION
    1. Real Device: ```'id=$UDID'```
    2. Simulator: ```'platform=iOS Simulator,name=iPhone X'```

2. Appium
```appium --nodeconfig config.json -p 4700```

3. Python
```python test.py```