Skip to content

Instantly share code, notes, and snippets.

@Lessica
Created May 13, 2023 15:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Lessica/97c3ee0172bf8e24820b71dfe44d53b3 to your computer and use it in GitHub Desktop.
Save Lessica/97c3ee0172bf8e24820b71dfe44d53b3 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