Why are my iOS e2e tests failing with "More than one device connected" in Flutter Drive?

Last updated: August 4, 2026

Context

When running end-to-end (e2e) tests using flutter drive on a CI/CD build machine, you may encounter the following error:

More than one device connected; please specify a device with the '-d <deviceId>' flag, or use '-d all' to act on all devices.

This happens because no iOS simulator is booted before the tests run, so flutter drive only detects macOS and Chrome as available devices and cannot automatically select an iOS simulator.

Answer

To resolve this issue, you need to boot an iOS simulator before running your tests and explicitly pin the device in your flutter drive command. The most reliable approach is to dynamically capture the simulator's UDID rather than hardcoding it, since UDIDs can change when the build machine is updated or the instance type changes.

Use the following script in your CI pipeline before running your tests:

  1. Pick an available iOS simulator and capture its UDID dynamically:

    UDID=$(xcrun simctl list devices available --json \
      | python3 -c "import sys,json;d=json.load(sys.stdin)['devices'];print(next(dev['udid'] for rt in d for dev in d[rt] if 'iOS' in rt))")
  2. Boot the simulator and wait until it is ready:

    xcrun simctl boot "$UDID"
    xcrun simctl bootstatus "$UDID" -b
  3. Pin the device when running your tests:

    flutter drive -d "$UDID" ... --flavor=development

If you prefer to manually select a specific simulator, you can first list all available devices on the build machine:

xcrun xctrace list devices

Then boot your chosen device using its UDID:

xcrun simctl boot <DEVICE_UDID>
xcrun simctl bootstatus <DEVICE_UDID> -b

Note: Avoid hardcoding a fixed UDID in your pipeline configuration, as these can change when the build machine is updated or the instance type is modified. The dynamic approach shown above is the most robust solution.