Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substitute libimobiledevice with go-ios #221

Merged
merged 48 commits into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e8889a9
refactor device list getting, pairing and dev image mounting
IGPenguin Oct 25, 2021
7302ed2
refactor ios_device_info method
IGPenguin Oct 25, 2021
f68a95d
use go-ios for taking screenshots
IGPenguin Oct 25, 2021
ebd60b1
fix shellcheck issue
IGPenguin Oct 25, 2021
2a41f1d
Merge branch 'version/1.3.0' into feature/go-ios
IGPenguin Nov 4, 2021
3ce428c
attach and use go-ios executeable
IGPenguin Nov 26, 2021
a2002ff
use attached go-ios exe
IGPenguin Nov 26, 2021
9bd76a9
use attached go-ios exe, run after installation
IGPenguin Nov 26, 2021
4c1b2a2
remove iuninstall as it is not currently available in go-ios
IGPenguin Nov 26, 2021
8d20a80
fix lint
IGPenguin Nov 26, 2021
e35c2bc
fix lint
IGPenguin Nov 26, 2021
7ca4fea
use attached go-ios exe
IGPenguin Nov 26, 2021
5918a06
fix silent output
IGPenguin Nov 26, 2021
d1c3240
use attached go-ios exe, add M1 check
IGPenguin Nov 26, 2021
b79c709
remove flaky date check
IGPenguin Nov 26, 2021
0b1a6ad
reintroduce iquicktime
IGPenguin Nov 26, 2021
9652058
use attached go-ios exe
IGPenguin Nov 26, 2021
a9021a2
add ikill
IGPenguin Nov 26, 2021
051a8d2
add ilaunch
IGPenguin Nov 26, 2021
df207fe
add package installed check
IGPenguin Nov 26, 2021
8f0eaf0
add ikill and ilaunch
IGPenguin Nov 26, 2021
a30c783
add ioptions
IGPenguin Nov 26, 2021
c3c20dc
add ioptions
IGPenguin Nov 26, 2021
74e1712
remove resolved TODO
IGPenguin Nov 26, 2021
0a86ba8
use proper emoji for ikill
IGPenguin Nov 26, 2021
7f096d1
remove icrashlogs as it is not supported by go-ios
IGPenguin Nov 26, 2021
aed62fc
update github issue link
IGPenguin Nov 26, 2021
65ddb71
add ilang
IGPenguin Nov 26, 2021
f1a2f87
handle unsupported language, improve output
IGPenguin Nov 26, 2021
cc5f4f5
resolve unnecessary pairing request
IGPenguin Nov 26, 2021
b833b5d
fix paring and developer image edge cases
IGPenguin Nov 26, 2021
e41c1b9
update readme
IGPenguin Nov 26, 2021
30e6d32
update changelog
IGPenguin Nov 26, 2021
7f97ffc
fix launch on multiple devices
IGPenguin Nov 26, 2021
bdf5b6c
optimize getting bundle id
IGPenguin Nov 26, 2021
d5fc252
fix getting bundle id for single device
IGPenguin Nov 26, 2021
f421319
install go-ios automatically, add various get package list methods
IGPenguin Dec 20, 2021
5af0846
add iuninstall
IGPenguin Dec 20, 2021
b40bde8
add ios/go-ios
IGPenguin Dec 20, 2021
592fded
fix typo
IGPenguin Dec 20, 2021
01f9e5b
remove unknown var from output
IGPenguin Dec 20, 2021
7fb67d0
improve output
IGPenguin Dec 20, 2021
e3a3cae
lenghten xcode timeout
IGPenguin Dec 20, 2021
4c5abaf
fix for multiple bundle ids, display error if launch failed
IGPenguin Dec 20, 2021
828bd8a
update readme
IGPenguin Dec 20, 2021
df06247
update changelog
IGPenguin Dec 20, 2021
8b03164
fix go-ios installation workflow
IGPenguin Dec 20, 2021
113999e
use https instead of ssh for cloning go-ios
IGPenguin Dec 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*DS_Store
*DS_Store
ios/go-ios
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ _Note: This repository is mainly focused on macOS compatibility, but majority of
3. Video footage is saved to ~/Desktop
4. File is compressed using ffmpeg

### 📹 iquicktime
* Run QuickTime and open video source picker (so you can choose a device right away)
* You may have to allow security system permission, so the script can access QuickTime application
* This is a fallback script for `irecord` on M1 macs as it is currently not working

## Manage applications
### 🚚 iinstall
* `iinstall some-app-file.ipa` Install .ipa (make sure to use properly signed build)
Expand All @@ -268,21 +273,28 @@ _Note: This repository is mainly focused on macOS compatibility, but majority of
* `iuninstall -w` Uninstall all third-party packages
* Skips some essential apps, edit IGNORED_PACKAGES in this script to customize the list to your needs

### 🚀 ilaunch
* `ilaunch` List third-party apps and choose one to run it
* `ilaunch -s` List os pre-installed apps and choose one to run it
* `ilaunch com.dummy.bundle.id.app` Run app by bundle id

### 🔪 ikill
* `ikill` List third-party apps and choose one to restart
* `ikill -s` List os pre-installed apps and choose one to restart
* `ikill com.dummy.bundle.id.app` Target specific app by passing bundle id as argument

## Manage device

### ⚙️ ioptions
* `ioptions` Open system settings application

### 💬 ilang
* `ilang <lang>` Change the device language to different one, according to ISO-639 (i.e. "cs")
* `ilang` Change the device language to different one, choose from a list of all supported

### 📜 ilog
* `ilog` Print system log output

### 💥 icrashlogs
* `icrashlogs` Import crash logs to ~/Desktop, choose whether to keep them in device storage
* `icrashlogs -k` Import crash logs, keep them in device storage
* `icrashlogs -r` Import crash logs, delete them from device storage
* You can import these logs to Xcode to make them more readable via symbolication
* Open relevant project in Xcode
* Click on Window > Devices and Simulators > View Device Logs
* Drag the .crash file onto the log list
* Readable crash log should appear in the list

### 📋 icheckdevice
* Print device information
* (Optional) Search for the device on [GSMArena](https://www.gsmarena.com/ "GSMArena")
Expand Down
2 changes: 1 addition & 1 deletion android/ainstall
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ install_app(){
adb -s "$1" install -t -r "$2" &> "$TEMPORARY_FILE"
if grep -q Failure "$TEMPORARY_FILE" ; then
echo "❌ Installation to $1 failed!"
echo "🤕 Uninstall existing version or troubleshoot the package."
echo "🤕 Uninstall existing version or troubleshoot the package"
echo "🔥 Error details: $(grep 'Failure' "$TEMPORARY_FILE" | sed 's/^.*: //')"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion android/areboot
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ LOCATION=$(dirname "$0")
source "$LOCATION"/../common_tools
android_choose_device

should_proceed "🔌 Do you really want to reboot $SELECTED_DEVICE_MODEL - $SELECTED_DEVICE?"
should_proceed "🔌 Do you really want to reboot - $SELECTED_DEVICE?"
echo "🔄 Rebooting the device..."
adb -s "$SELECTED_DEVICE" reboot &> /dev/null
14 changes: 10 additions & 4 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
🌍 https://github.com/IntergalacticPenguin/mobile-toolkit

🆕 Notable changes:
🚀 Optimized iOS device picker
🔊 Add atalkback
✨ Add new iOS device translations
💣 Using go-ios for all iOS scripts instead of libimobiledevice
(Remove unused tools via `brew uninstall libimobiledevice && brew uninstall ideviceinstaller`)
🚀 Added ilaunch, ikill, ioption, ilang, atalkback
🏁 iinstall runs the installed app automatically
🧟‍♀️ Reintroduce iquicktime as irecord fallback for M1 macs
⚰️ Removed icrashlogs (perhaps temporarily, depends on go-ios maintainer)
🩹 Fix Android 12 foreground package detection
✨ Added new iOS device translations

🚨 Action needed:
🔐 Ignore the warning about running an untrusted software and enable access in security settings
✨ Make sure to download and install new version of videosnap tool
🔗 https://github.com/matthutchinson/videosnap/releases/download/v0.0.7/videosnap-0.0.7.pkg
🔗 https://github.com/matthutchinson/videosnap/releases/download/v0.0.8/videosnap-0.0.8.pkg
125 changes: 94 additions & 31 deletions common_tools
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ android_is_package_installed() {
adb -s "$SELECTED_DEVICE" shell pm list packages -f | sed -e 's/.*=//' | grep -w "$1" &> /dev/null
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
echo "🤷‍ Package \"$1\" is not installed."
echo "🤷‍ Package \"$1\" is not installed"
exit 1
fi
}
Expand Down Expand Up @@ -191,54 +191,98 @@ do
##############################################################################
### iOS

check_go_ios_version(){
if ! [ -x "$(command -v "go-ios")" ]; then
install_go_ios
else
GO_IOS_VERSION=$(go-ios --version)
#echo "Version of go-ios is: $GO_IOS_VERSION"
fi
}

install_go_ios(){
echo "⏳ Installing https://github.com/danielpaulus/go-ios..."
check_dependency "go"
CURRENT_DIR="$PWD"
TOOLKIT_IOS_LOCATION=$(dirname "$0")
git clone "https://github.com/danielpaulus/go-ios.git" "$TOOLKIT_IOS_LOCATION/go-ios" &> /dev/null
cd "$TOOLKIT_IOS_LOCATION/go-ios"

go build .
chmod +x "go-ios"
mv "go-ios" "go-ios-temp"
mv "go-ios-temp" ..
cd ..
rm -rf "$TOOLKIT_IOS_LOCATION/go-ios"
mv "go-ios-temp" "go-ios"

cd "$CURRENT_DIR"
}

prompt_xcode_launch(){
echo "❌ Developer image is not mounted and/or device screen is locked"
should_proceed "❓ Do you want to open Xcode to fix it? (make sure you have the latest version)"
open -a Xcode
echo "⏳ Waiting for Xcode to launch..."
sleep 8
while true ; do
sleep 2
if [[ $(ps aux | grep -v grep | grep -c Xcode) -ne 0 ]]; then
break
fi
done
sleep 4
osascript -e 'quit app "Xcode"'
}

ios_wait_for_device(){
echo "⏳ Waiting for iOS device..."
ios_get_devices
while [ ${#IOS_USB_DEVICES[@]} -lt 1 ];
do
sleep 1
ios_get_devices
done
delete_lastline
ios_get_devices(){
check_go_ios_version
check_dependency "jq"
IOS_USB_DEVICES=( $(go-ios list --nojson | sort -u) )
}

ios_check_developer_image_and_pairing(){
IS_MOUNTED=$(ideviceimagemounter -u "$1" -l)
if [[ $IS_MOUNTED == *"Error"* ]] || [[ $IS_MOUNTED == *"error"* ]] ; then
read -r -p "❌ Device not paired or screen locked - reconnect/unlock it (one at a time) and press ENTER..."
echo "🤝 Requesting pairing..."
idevicepair pair &> /dev/null
read -r -p "❓ Tap \"Trust\" button on the device screen and press ENTER..."
sleep 1
ios_check_developer_image_and_pairing "$1"
ios_pair_device(){
go-ios pair --udid="$1" --nojson &> /dev/null
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
read -p "❌ Device is not paired - reconnect it, unlock screen, tap \"Trust\" and press ENTER..."
ios_pair_device "$1"
fi
}

if [ ${#IS_MOUNTED} -eq 0 ] ; then
ios_check_pairing(){
go-ios info --udid="$1" &> "$TEMPORARY_FILE"
if cat "$TEMPORARY_FILE" | grep -q 'UntrustedHostBUID' ; then
read -r -p "❌ Device is not paired - reconnect it, unlock screen, tap \"Trust\" and press ENTER..."
ios_pair_device "$1"
fi
if cat "$TEMPORARY_FILE" | grep -q 'could not retrieve PairRecord' ; then
read -r -p "❌ Device is not paired - reconnect it, unlock screen, tap \"Trust\" and press ENTER..."
ios_pair_device "$1"
fi
}

ios_check_developer_image(){
IS_MOUNTED=$((go-ios image list --udid="$1" --nojson) 2>&1)
if [[ $IS_MOUNTED == *"none"* ]]; then
prompt_xcode_launch
ios_check_developer_image "$1"
fi
}

ios_check_developer_image_and_pairing(){
ios_check_pairing "$1"
ios_check_developer_image "$1"
}

ios_device_info(){
ios_check_developer_image_and_pairing "$1"
MANUFACTURER="Apple"
ideviceinfo -s -u "$1" > "$TEMPORARY_FILE"
MODEL=$(ios_translate_name "$(grep "HardwareModel" "$TEMPORARY_FILE" | cut -d\ -f2)")
VERSION=$(grep "ProductVersion" "$TEMPORARY_FILE" | cut -d\ -f2)
go-ios info --udid="$1" > "$TEMPORARY_FILE"
MODEL=$(ios_translate_name "$(cat "$TEMPORARY_FILE" | jq -r '.HardwareModel')")
VERSION=$(cat "$TEMPORARY_FILE" | jq -r '.ProductVersion')
INFO=$(printf "%s) %s %s %s - %s" "$NUMBER" "$MANUFACTURER" "$MODEL" "$VERSION" "$ID")
}

ios_get_devices(){
IOS_USB_DEVICES=( $(idevice_id -l | sort -u) )
}

ios_choose_device(){
check_for_update
ios_get_devices
Expand Down Expand Up @@ -274,9 +318,28 @@ ios_choose_device(){
else
SELECTED_DEVICE="${IOS_USB_DEVICES[0]}"
fi
}

ios_get_installed_package_list(){
echo "⏳ Getting third-party package list..."
INSTALLED_PACKAGES=($(go-ios apps --udid="$1" | jq -r '.[] | .CFBundleIdentifier'))
}

ios_get_all_package_list(){
echo "⏳ Getting all package list..."
INSTALLED_PACKAGES=($(go-ios apps --udid="$1" | jq -r '.[] | .CFBundleIdentifier'))
SYSTEM_PACKAGES=($(go-ios apps --udid="$1" --system | jq -r '.[] | .CFBundleIdentifier'))
ALL_PACKAGES=("${INSTALLED_PACKAGES[@]}" "${SYSTEM_PACKAGES[@]}")
}

SELECTED_DEVICE_MODEL=$(ios_translate_name "$(ideviceinfo -u "$SELECTED_DEVICE" | grep "HardwareModel" | cut -d\ -f2)")
SELECTED_DEVICE_VERSION=$(ideviceinfo -u "$SELECTED_DEVICE" | grep "ProductVersion" | cut -d\ -f2)
ios_is_package_installed(){
ios_get_all_package_list "$SELECTED_DEVICE"
echo "${ALL_PACKAGES[*]}" | grep -w "$1" &> /dev/null
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
echo "🤷‍ Package \"$1\" is not installed"
exit 1
fi
}

ios_translate_name(){
Expand Down Expand Up @@ -527,7 +590,7 @@ yes_or_no(){
;;
*)
echo
echo "🤷‍ Invalid option."
echo "🤷‍ Invalid option"
yes_or_no "$1"
;;
esac
Expand Down
18 changes: 4 additions & 14 deletions ios/icheckdevice
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,16 @@
LOCATION=$(dirname "$0")
source "$LOCATION"/../common_tools
ios_choose_device
ios_device_info "$SELECTED_DEVICE"

GSM_URL='https://www.gsmarena.com/res.php3?sSearch='

MANUFACTURER=Apple
INFO=$(printf "%s %s - iOS %s" "$MANUFACTURER" "$SELECTED_DEVICE_MODEL" "$SELECTED_DEVICE_VERSION")
INFO=$(printf "%s %s - iOS %s" "$MANUFACTURER" "$MODEL" "$VERSION")

PHONE_URL=$GSM_URL$SELECTED_DEVICE_MODEL
PHONE_URL=$GSM_URL$MODEL

echo "📱 $INFO"
echo " • ID: $SELECTED_DEVICE"

echo -n "📆 Checking date"
LOCAL_DATE=$(date|cut -f1,2 -d':')
DEVICE_DATE=$(idevicedate -u "$SELECTED_DEVICE"|cut -f1,2 -d':')
if [ "$DEVICE_DATE" != "$LOCAL_DATE" ]
then
echo " - ❗️ Date is set manually"
else
echo " - ✅ OK"
fi
echo "📱 $INFO - ID: $SELECTED_DEVICE"

should_proceed "🌐 Search for the device on GSMArena?"
open "$PHONE_URL"
63 changes: 0 additions & 63 deletions ios/icrashlogs

This file was deleted.

Loading