When using localizable.strings with many entries in your XCode project you sooner or later may use a key more than once. Is it possible to let XCode find that case and issue a warning about it?
Apple's Resource Programming mentions the genstrings tool, but usually you don't use that yourself in XCode. So, how can I let XCode detect duplicate keys in such files without manually running genstrings?
Bounty note: to earn the bounty a solution must fully integrate with XCode if it uses external resources like scripts, that is, it must work with input files given in XCode, mark a build as fail in case of duplicates and must not trigger for false positives like empty lines or comments.
cut -d' ' -f1 Localizable.strings | sort | uniq -c
type this command in the terminal and you get a list saying how often each key is used.
use -d instead of -c and you only get duplicates
#!/bin/bash
c=`expr $SCRIPT_INPUT_FILE_COUNT - 1`
for i in $(seq 0 $c)
do
var="SCRIPT_INPUT_FILE_$i"
FILENAME=${!var}
DUPES=`cut -d' ' -f1 "$FILENAME" | sort | uniq -d`
while read -r line; do
if [[ $line == "\""* ]] ;
then
echo "warning: $line used multiple times -"
fi
done <<< "$DUPES"
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With