Skip to content

Instantly share code, notes, and snippets.

@po6ix
Forked from Lessica/fetch-libimobiledevice.sh
Created September 29, 2023 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save po6ix/132b127f77a2e49bf6feab9c64c1b9bd to your computer and use it in GitHub Desktop.
Save po6ix/132b127f77a2e49bf6feab9c64c1b9bd to your computer and use it in GitHub Desktop.
Fetch libraries and executables for macOS from libimobiledevice artifacts. This script will make executables runnable without install them to specific paths.
#!/bin/sh
set -e
if ! test -x "`which ldid`"; then
echo "Cannot find ldid, you may install it via Homebrew."
exit 1
fi
if [ ! -d "$(xcode-select -p)" ]; then
echo "You need to install Xcode to use this script."
exit 1
fi
EFFECTIVE_URL=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/NyaMisty/libimobiledevice-nightly-pkg/releases/latest/)
EFFECTIVE_TAG=$(basename $EFFECTIVE_URL)
if [ ! -f macOS.tar ]; then
curl -Lo macOS.tar "https://github.com/NyaMisty/libimobiledevice-nightly-pkg/releases/download/$EFFECTIVE_TAG/macOS.tar"
fi
tar xvf macOS.tar -C .
mv ./usr/local/lib/*.dylib ./usr/local/bin || true
for FILENAME in ./usr/local/bin/*; do
if [ ! -L $FILENAME ]
then
LIBLIST=$(otool -arch arm64 -L $FILENAME | cut -d' ' -f1-1 | xargs | cut -d' ' -f2-)
for LIBNAME in $LIBLIST; do
LIBBASENAME=$(basename $LIBNAME)
if [ -e "./usr/local/bin/$LIBBASENAME" ]; then
install_name_tool -change $LIBNAME @executable_path/$LIBBASENAME $FILENAME
ldid -S $FILENAME
fi
done
fi
done
open ./usr/local/bin
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment