What is an iOS Simulator?
The iOS Simulator is a part of Xcode (Apple’s IDE) that mimics the behavior of an iOS device on a Mac. It allows developers to:
Run and test iOS apps without needing a physical device.
Simulate different iPhone/iPad models, screen sizes, and iOS versions.
Debug and test UI/UX, performance, and network behavior.
iOS Simulator runs only on macOS.
How to Connect iOS Simulator with Appium
Below things should be ready before proceeding to connect ios simulator with Appium:
Below things should be ready before proceeding to connect ios simulator with Appium:
| Tool | Description |
|---|---|
| macOS | Required to run iOS Simulator |
| Xcode | Includes iOS Simulator |
| Appium | Install via Desktop App or npm install -g appium |
| Appium Doctor | To verify environment: npm install -g appium-doctor |
| Java | JDK 11+ installed |
| Maven or Gradle | Java dependency manager |
| Appium Java Client | Add to your project (e.g., in pom.xml) |
| WebDriverAgent | Used by Appium to automate iOS |
Steps to Connect iOS Simulator with Appium
1. Start iOS Simulator
Open Terminal and type:
open -a Simulator
Or launch from Xcode > Xcode > Open Developer Tool > Simulator
2. Start Appium Server
You can:
Launch Appium Desktop > Start Server
Or use CLI:
appium
3. Check Simulator Details
List available simulators:
xcrun simctl list devices
Get udid of the simulator you want to use.
4. Write Java Test Script
Java Code to Launch App in iOS Simulator using Appium
import io.appium.java_client.ios.IOSDriver; import io.appium.java_client.remote.MobileCapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import java.net.MalformedURLException; import java.net.URL; public class IOSSimulatorTest { public static void main(String[] args) throws MalformedURLException { DesiredCapabilities caps = new DesiredCapabilities(); // Simulator details caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS"); caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "16.4"); // Replace with your simulator version caps.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 14"); caps.setCapability(MobileCapabilityType.UDID, "auto"); // Or specific UDID caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest"); // App details caps.setCapability(MobileCapabilityType.APP, "/Users/yourname/Downloads/YourApp.app"); // Replace with path to .app or .ipa file // Optional caps.setCapability("noReset", true); caps.setCapability("newCommandTimeout", 300); IOSDriver driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), caps); // Example Test Action System.out.println("App Launched Successfully!"); driver.quit(); } }
Important Points:
- Replace the
.appfile path with your built app (from Xcode or CI).
- Use
xcrun simctlor Appium Inspector to inspect app elements.
XCUITestis the only supported automation engine for iOS 10+.