tag_missing_resources.sh 2.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!/bin/sh

# tag_missing_resources.sh
#
# Copyright (C) 2012  Belledonne Comunications, Grenoble, France
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# Created by Gautier Pelloux-Prayer on 2014/10/09.
# This script will search for resources contained in Resources/ folder but not
# present in xcode build project project.pbxproj. Since we do not use folder
# references (because of http://vocaro.com/trevor/blog/2012/10/21/xcode-groups-vs-folder-references/),
# it helps keeping resources synced.
# Basically, the script will set a red tag to every files not added in the xcode project. User will then
# have to drag&drop these into xcode project. Red tags are automatically reset by the script on execution


if [ $# != 0 ]; then
	echo "Usage: $0"
	exit 0
fi

if ! which tag &>/dev/null; then
	echo "Please install tag: port install tag or brew install tag"
	exit 1
fi

# quit on first error
set -e

# go where the script is
cd $(dirname $0)

already_sync=$(mktemp -t tag_missing_resources)
to_sync=$(mktemp -t tag_missing_resources)

grep -oE '([^ /"])*.png' ../linphone.xcodeproj/project.pbxproj | sort -u > $already_sync
50
find ../Resources/ -not -path '*/Images.xcassets/*' -name '*.png' -exec basename {} \; | sort -u > $to_sync
51 52

# clean red tags
53 54
for file in $to_sync $already_sync; do
	find ../Resources -name $file -exec tag -r red {} \;
55
done
56 57 58 59

# 'comm' command output files contained in second file but not in first nor in common
non_synced_files=$(comm -13 $already_sync $to_sync)

60
for file in $non_synced_files; do
61 62
	find ../Resources -name $file -exec tag -a red {} \;
done
63 64 65 66 67 68 69 70 71 72 73

rm $already_sync $to_sync

echo "**********************
Done. Created red tags for non-synced files:
${non_synced_files}.

Drag and drop these files into your xcode project. You can go to the folder using:
	open $PWD/../Resources
Then use search feature and type 'red', select the red tag and go!
**********************"