iosswiftxctestuidevice

Get Device name in XCTest (UITesting)


I am having tough time in finding the device name when running the UITesting for my Target. Below code returns MacBook's name when running on Simulator.

UIDevice.current.name


Solution

  • That´s because you´re running on your Mac and that´s the name of it.

    UIDevice.current.name returns

    The name identifying the device.

    Checkout the reference here for what values that UIDevice has to identify it self and the operating system.

    So that´s the way to get the device name.