Using Real Devices with Anka

Executing XCTests on Real Devices with Anka

Anka provides ability to manage and execute tests (e.g. through XCTest) on multiple physical mobile devices connected to the host, through Anka VMs. Use anka usb command to manage real devices connected through the USB interface.

Note For real devices running iOS 12, follow the steps outlined in this blog to claim the device

Using real devices with Anka Build

You have multiple Anka Build nodes(host machines) with real devices attached.

  • Step 1 - Create node groups in Anka Build Controller corresponding to different device types. For example, all nodes which have iPhone X attached, put them in iPhoneX group. This is only required if you have multiple nodes with same device type attached.

  • Step 2 - On all the nodes in this group, claim the iPhone X with the same claimname.

anka usb list anka usb claim -n <claimname> LOCATION_NAME_OR_ID

  • Step 3 - Attach it to the VM with anka modify command. Use the claimname from Step 2.

anka modify vmname add usb-device claimname

  • Step 4 - Suspend the VM.

anka suspend VMname

  • Step 5 - Push the VM to the registry with anka registry push command.

  • Step 6 - Start a job in your CI which provisions VM in the group(previously definied in Step 1).

  • Step 7 - The VM provisioned will have access to iPhone X device.

  • Step 8 - When the VM is deleted, the device will be available for the next provisioned VM.

Using real devices with Anka Flow

Use anka usb to claim a single connected device and then attach it to a VM to run tests against it. You can attach it in a static manner using anka modify command or at run time using anka start -d command.

anka usb [OPTIONS] COMMAND [ARGS]...

  Do actions on USB devices

  --help  Show this message and exit.  [optional]

  claim    make a device available for attaching to vms,...
  list     list all available usb devices on this host
  release  release a device back to host availability,...

  make a device available for attaching to vms

  -n, --claim-name TEXT  claim name could be used as additional name
  --help                 Show this message and exit.

anka modify vm add usb-device --help
Usage: anka modify add usb-device [OPTIONS] DEVICE

  -f, --force  skip device validation
  --help       Show this message and exit.
anka  start VMNAME

or (use dynamic configuration):


Releasing real devices

Use any of these commands to release device from the VM.

anka usb release, anka stop, anka suspend