Skip to content

Instantly share code, notes, and snippets.

@binzume
Created December 10, 2019 10:30
Show Gist options
  • Save binzume/ddf0dc55de5abcb0d7180a818928b6ca to your computer and use it in GitHub Desktop.
Save binzume/ddf0dc55de5abcb0d7180a818928b6ca to your computer and use it in GitHub Desktop.
Command line tool to communicate with iOS device as like ADB
#!/bin/bash
#
# Command line tool to communicate with iOS device as like ADB
# This is wrapper script for libimobiledevice and ios-deploy.
#
## Usage:
## idb [-s DEVID] [-b BUNDLE_ID] COMMAND [PARAMS...]
## idb devices
## idb logcat
## idb reboot
## idb install APP_FILE [--debug]
## idb uninstall BUNDLE_ID
## idb push LOCAL_PATH DST_PATH
## idb pull PATH LOCAL_PATH
## idb ls [PATH_PREFIX]
## idb rm PATH
## idb bundles
## idb screencap
## idb init-tools
##
## First, run 'idb init-tools' to install libimobiledevice and ios-deploy.
##
while :
do
case "$1" in
"-s") DEVICE_ID=$2; shift 2 ;;
"-u") DEVICE_ID=$2; shift 2 ;;
"-b") BUNDLE_ID=$2; shift 2 ;;
*) break ;;
esac
done
DEVPARAM="${DEVICE_ID:+-u} $DEVICE_ID"
CMD=$1; shift
case $CMD in
"devices") idevice_id -l ;;
"logcat") idevicesyslog $DEVPARAM ;;
"screencap") idevicescreenshot $DEVPARAM ;;
"reboot") idevicediagnostics restart $DEVPARAM ;;
"install") ios-deploy --bundle $@ ;;
"uninstall") ios-deploy --uninstall_only --bundle_id $@ ;;
"pull") ios-deploy --bundle_id ${BUNDLE_ID:?BUNDLE_ID is required} --download=$1 ${2:+--to} $2 ;;
"push") ios-deploy --bundle_id $BUNDLE_ID --upload=$1 ${2:+--to} $2 ;;
"ls") ios-deploy --bundle_id ${BUNDLE_ID:?BUNDLE_ID is required} --list | grep -e "^[^/]" -e "^$1" ;;
"rm") ios-deploy --bundle_id ${BUNDLE_ID:?BUNDLE_ID is required} --rm $@ ;;
"bundles") ios-deploy --list_bundle_id ;;
"init-tools") brew install autoconf automake pkg-config usbmuxd && brew install --HEAD libimobiledevice && brew install ios-deploy ;;
*) grep "^##" $0 >&2 ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment