Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Mobile / iOS

Commands for Controlling an iOS device in Windows using libimobile

4.11/5 (2 votes)
19 Oct 2015CPOL3 min read 37.7K  
From the command line, you can control your iOS device using the libimobile tools, these are some common commands.

Introduction

Download the idevice tools from Quamotion here:

Once you have installed the binaries, add the path to your system path for convenience.

Note that to use most of these device commands, the device itself must be:

  • Supported in terms of the device and the OS version
  • Activated
  • Trusted
  • Have a developer disk mounted (if you want to install/run an app on the device)

All of these operations can be performed from the command line (with the exception of accepting the trust dialog or pairing the device, this requires manual intervention).

If you reboot the device, you must re-pair (or trust) the device. So generally, it's not a great idea to reboot the device, as you will have to be physically present to get it talking again (not very good if you are remotely testing).

Specifying the Device

If you want to direct your command to a specific device, then use the -u (or in some cases -U). Pass in the DUID of the device, and that way if you have several USB connected devices, you can be sure where your command is going. Note to get the DUID, either list all the devices (using idevice_id -l), or go to itunes and click on the Serial Number of the Device and it will show the DUID eventually.

Getting Help

All the commands support the -h optional parameter. Use this to get limited help on the command.

Commands

Here are the commands:

idevice_id -l

This command will list all the connected (via USB) Android devices. Note that the device unique identifier is listed, use this when you have several devices connected and want to direct a command at a specific device. You normally preceed this with a -u, but sometimes it can be a -U so be careful!


ideviceactivation activate -u <DUID> 

This activates the device.


idevicecrashreport -k .

The will copy all the crash reports from the device without deleting them from the device. It will copy all the reports to the specified folder, in this case. (local)


idevicename

Get the name of the device.


ideviceinfo

Prints out various information about the device, including Mac addresses, activation state, CPU type, OS version, etc.


idevicesyslog

Prints the system log from the device. Note this proces will continue to execute and print out each TTY line. If your application spews out TTY, you can capture it from the system log, without having to keep a thread alive that has started your application on the device.


idevicepair pair -u <DUID>

Before you can use a device from a PC, you must trust it. This is a manual process and requires you to accept the trust dialog on the device, this command will instigate that process. Accept the dialog in the GUI and you can now control the device.


idevicepair unpair -u <DUID>

Unpair (un-trust) the device. Note you will not be able to do much with the device if it is unpaired.


idevicepair validate -u <DUID>

Check the status of the device.


ideviceimagemounter -u <DUID> -t Developer DeveloperDiskImage.dmg DeveloperDiskImage.dmg.signature

If you want to install and run actual applications on the iOS device, then you must mount a developer disk. The command above does this. You will need the .dmg and .signature file to get these from your itunes installation folder.


idevicescreenshot

Take a screen shot of the device.


ideviceinstaller -u <DUID> -l -o xml

List all the installed applications on the device. Note that the full path is given, search for any line with .app for the applications on the device.


idevicedebug -u <DUID> run <Identity>

This will run the specified application on the device. You need the developer disk mounted to do this.


idevicediagnostics -u <DUID> restart

Reboot the device.

Conclusion

That's all for now. Happy iOSing

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)