Disconnect an iOS device remotely
I'm trying to use a remote server for building an iOS app. We have a script that discovers all connected devices and then runs the deployment command to them, if it succeeds it moves to the next step and uploads it to the store for us. This is the command that finds the iOS devices
instruments -s devices
It lists all the real devices and the available simulators, which we screen out with grep, then we cycle through what's left and use this
ionic capacitor run ios --prod --target $line
However, one of the devices has become locked and we can't physically get the machine for a week or more. which means our scripts break
[error] ERR_DEVICE_LOCKED: Device still locked after 1 minute. Aborting
I can use Screen Sharing to see the screen, and I can ssh to it. I've hit the 'eject' icon next to its name in Finder but it still appears in the instruments
readout. Is there anyway to filter out locked device IDs?
One possible way would be to install libimobiledevice
from HomeBrew, and then run a command like this:
ideviceinfo -u XXX -k PasswordProtected
where you replace XXX with the UDID for the device. It should be able to tell you whether the device is locked or not - if it is locked, you could then just skip your ionic
command for that device.
Another option would simply be to examine the output from the ionic
command and store the fact that it gave you that error reporting the device as locked. Then you could look that up in subsequent runs and skip the device. I would store a timestamp along with the information, so that you could cache the fact for a limited time period only (for example 1 hour).