Skip to content

Instantly share code, notes, and snippets.

@yifanz
Created July 18, 2016 17:40
Show Gist options
  • Save yifanz/83a85a90b48ee267aec724bed92ce853 to your computer and use it in GitHub Desktop.
Save yifanz/83a85a90b48ee267aec724bed92ce853 to your computer and use it in GitHub Desktop.
macOS script: Transitively list all dynamic library dependencies
#!/bin/bash
deps=""
find_deps()
{
bin=$1
while read lib; do
lib=${lib%%\(*\)}
lib=${lib%%[[:space:]]}
lib=${lib##[[:space:]]}
if [[ ! "$deps" =~ "$lib" ]]; then
deps+="$lib"$'\n'
find_deps "$lib"
fi
done < <(otool -L "$bin" | tail -n +2)
}
find_deps "$1"
deps=${deps%%[[:space:]]}
echo "$deps"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment