Commits

Ivan Vučica committed 8641ccd

Added basic Mac App Store validation of external dependencies

  • Participants

Comments (0)

Files changed (1)

File checkapp-mas.sh

+#!/bin/sh
+# Unofficial App Validator for Mac App Store
+
+# Author: Ivan Vucica
+# Released under BSD license
+# (c) 2011
+
+# This validator performs some basic checks before uploading to the
+# Mac App Store. Runs on OS X. First argument needs to be ONLY the app
+# bundle name. Any kind of path is not accepted (including .).
+#
+# Recommended workflow: In Xcode's Organizer, rightclick on an app archive,
+# and select "Show in Finder". Open a terminal. Punch in "cd ", drag and
+# drop the archive folder. Press enter.  Run the script by passing the 
+# app bundle name.
+
+# Current list of checks:
+# * Does the executable depend on some external libs?[1]
+# * Does any framework depend on some external libs?[1]
+
+# Extra descriptions:
+# [0] Presumptions
+# a) Your executable name matches your app bundle name. No attempt is made
+#    to read Info.plist.
+# b) Any frameworks you use are in ~/Library/Frameworks or 
+#    /Library/Frameworks
+#
+# [1] Dependancies on external libs
+# This is checked by running 'otool -L'. If output contains a line that
+# contains string "Library/Framework", but does not contain "System", then
+# that line defines an external dependencies. While this may be false,
+# if you follow good coding practices elsewhere, this is a valid check.
+#
+# Note that "default install name" containing an external dependency appears
+# to be a valid reason for rejection.
+#
+
+# And now for the code:
+
+VALIDATED=1
+REASON=""
+APPNAME="$1"
+EXENAME="${APPNAME%.app}"
+cd "$1"
+APPPATH="`pwd`"
+
+# * Does the executable depend on some external libs?[1]
+cd "Contents/MacOS"
+BADLIBS=`otool -L "$EXENAME"|grep Library\/Frameworks | grep -v System`
+if [ ! -z "${BADLIBS}" ] ; then
+	echo "== PROBLEM WITH EXECUTABLE "
+	echo $BADLIBS
+	VALIDATED=0
+	REASON="${REASON}Executable has external dependencies.\n"
+fi
+
+
+# * Does any framework depend on some external libs?[1]
+cd "$APPPATH"
+cd Contents/Frameworks
+for i in * ; do 
+	cd $i
+	
+	BADLIBS=`otool -L ${i%.framework}|grep Library\/Frameworks | grep -v System`
+	if [ ! -z "${BADLIBS}" ] ; then
+		echo "== PROBLEM WITH $i"
+		echo $BADLIBS
+
+		VALIDATED=0
+
+		REASON="${REASON}Framework '$i' has external dependencies.\n"
+	fi
+	cd ..
+done
+
+
+# Ok... are we done?
+
+if [ $VALIDATED -eq 1 ] ; then
+	echo
+	echo
+	echo "App is validated!"
+	exit 0
+else
+	echo
+	echo
+	echo "App validation failed:"
+	echo -e $REASON
+	exit 1
+fi