You would need to code that yourself. I have something similar where we automatically get the uuid before starting Appium, searching connected devices by name. However you programmatically start Appium, run your code first and set capabilities accordingly. There are many approaches, you’ll need to find the one that fits your testing infrastructure and coding language best. I’d try an algorithm like:
- query for real device with ‘idevice_id -l’ which should be installed with libimobiledevice
- if query is null, use adb to query for devices, ‘adb devices’ (note you’ll have to parse out any emulators, there may be a better command for this)
- set capabilities and start Appium
Good luck!