This script will search for zombie strings, i.e. strings not being used, in an Xcode project.
Download it or create it yourself and add it to your user folder.
#!/bin/bash
rootFolder=.
if [[ $1 ]]; then
rootFolder=$1
fi
allLocalisableFiles=$(find $rootFolder -type f -name "*.strings");
for localisableFile in $allLocalisableFiles; do
echo -e "\n🔎 Inspecting:" $localisableFile
while read p; do
IFS=" = ";
string=($p);
key=${string[0]}
if [[ ${#string[@]} -gt 1 ]] && [[ $key == \"* ]]; then
if ! grep -rsq --include=\*.{swift,m,h} $key $rootFolder; then
echo "⚠️ " $key "is not used 💀"
fi
fi
unset IFS;
done < $localisableFile
done
Add the following code to .bash_profile
:
function checkZombieStrings() {
currentPath="$PWD"
sudo sh ~/zombie_strings.sh $currentPath
}
- Open the terminal and navigate to your project folder;
- Call
checkZombieStrings()
; - Check the terminal for a listing of all zombie strings;
- ?
- Profit.