Has anyone a one-line to find unused images in an Xcode project? (Assuming all the files are referenced by name in code or the project files - no code generated file names.)
Using the other answers, this one is a good example of how to ignore images on two directories and do not search occurrences of the images on the pbxproj or xcassets files (Be careful with the app icon and splash screens). Change the * in the --ignore-dir=*.xcassets to match your directory:
#!/bin/bash
for i in `find . -not \( -path ./Frameworks -prune \) -not \( -path ./Carthage -prune \) -not \( -path ./Pods -prune \) -name "*.png" -o -name "*.jpg"`; do
file=`basename -s .jpg "$i" | xargs basename -s .png | xargs basename -s @2x | xargs basename -s @3x`
result=`ack -i --ignore-file=ext:pbxproj --ignore-dir=*.xcassets "$file"`
if [ -z "$result" ]; then
echo "$i"
fi
done