Skip to content

Instantly share code, notes, and snippets.

@tabrindle
Created September 12, 2013 13:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tabrindle/6537052 to your computer and use it in GitHub Desktop.
Save tabrindle/6537052 to your computer and use it in GitHub Desktop.
Sencha build script for 'build phases' inside Xcode - Includes MD5 comparison
OLDMD5=`cat $PROJECT_DIR/www/project.md5`
NEWMD5=`ls -altR $PROJECT_DIR/www/app/ | grep -viw ".DS_Store" > $PROJECT_DIR/www/md5Helper.txt && md5 $PROJECT_DIR/www/md5Helper.txt | awk '{print $4}'`;
SENCHA_CMD="/Users/${USER}/bin/Sencha/Cmd/3.1.2.342"
echo "Old MD5 - $OLDMD5"
echo "New MD5 - $NEWMD5"
if [ "$OLDMD5" = "$NEWMD5" ]
then
echo "MD5s are the same. NOT Running Sencha Build."
else
echo "MD5s are different. Running Sencha Build."
echo $NEWMD5 > $PROJECT_DIR/www/project.md5
cd $PROJECT_DIR/www
$SENCHA_CMD/sencha app build testing
fi
@tabrindle
Copy link
Author

Automatic Sencha build on each "run" in Xcode

Navigate to the file browser on the right -> select Targets -> select (tab) Build Phases

Look at the bottom right, select "Add Build Phase" -> select "Add Run Script"

Reposition the new Run Script item to just under item "Target Dependencies", and before item "Copy www directory"

Expand your new Run Script item, and in the text area, paste the example script:

_Ensure you have the same version of Sencha Cmd_

​​The two main types of sencha builds that are useful for our purposes are "package" and "testing". To implement a testing build, change the last line of the script to:

$SENCHA_CMD/sencha app build testing​​

​​The main difference between package and testing is that testing is not minified, and therefor is easier to debug

Under the next item "Copy www directory", Modify the SRC_DIR variable to the following template​

www/build/[Sencha Project Name]/[Type of build]​

Create a two files in the www/ directory. one labled project.md5, and one called md5Helper.txt. Both can be empty files.

​This script in addition to running the appropriate sencha build commands will compare an md5 of the projects previous state when the script was last run, with a new md5. If the project is unchanged, the script will not complete a sencha build operation, saving you 30-60 seconds, depending on the project and the computer.

​Done! When you select "run" the next time, Xcode will pause for a few seconds to run the custom script that was just set up, then create the app bundle as usual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment