From 4a28516f66b2db4f2471337ca3e22534069d03f8 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 9 Oct 2014 11:45:41 +0200 Subject: [PATCH] Add script to automatically sync resources between xcode and filesystem --- Tools/tag_missing_resources.sh | 69 ++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 Tools/tag_missing_resources.sh diff --git a/Tools/tag_missing_resources.sh b/Tools/tag_missing_resources.sh new file mode 100755 index 000000000..74af5dd48 --- /dev/null +++ b/Tools/tag_missing_resources.sh @@ -0,0 +1,69 @@ +#!/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 +find ../Resources/ -name *.png -exec basename {} \; | sort -u > $to_sync + +# clean red tags +tag -r red $to_sync + +# 'comm' command output files contained in second file but not in first nor in common +non_synced_files=$(comm -13 $already_sync $to_sync) + +cd ../Resources/ && tag -a red $non_synced_files && cd - 1>/dev/null + +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! +**********************"