less than 1 minute read

Getting iOS Simulator UDID from tests

Sometimes it can be useful to have the UDID of the iOS simulator handy for automation purposes. Let’s learn how to extract it within XCTest.

Right off the boat 🤿

import XCTest

class SampleTest: XCTestCase {

  func testSimulatorUDID() {
    let env = ProcessInfo.processInfo.environment
    let udid = env["SIMULATOR_UDID"] ?? ""
    XCTAssertNotEqual(udid, "")
  }
}
  1. Open an Xcode project
  2. Create a test file
  3. Fill it with the code above
  4. Run it on any iOS Simulator
  5. Enjoy 🤠

Updated: