Create A Template App with Secha Touch and PhoneGap

Install the following packages:

  • PhoneGap SDK
  • Sencha Touch SDK
  • Sencha Cmd
  • Adroid Development Toolkit

Create this Bash script for running the Sencha Cmd and PhoneGap generators. You can add it your ~/bin directory or anywhere where it is visible from your file path. Edit the paths to match your specific versions of Sencha Touch and PhoneGap.

#!/bin/bash

PROJECT_DIR="anywhere"
PROJECT_NAME="Anywhere"
PACKAGE_NAME="com.globalbin.mobile"
DEV_DIR="~/Development"
SENCHA_SDK="~/touch-2.2.0"
SENCHA_CMD="~/bin/Sencha/Cmd/3.1.1.274"
CORDOVA_VER="2.7.0"
PHONEGAP="~/phonegap-2.7.0/lib"
APP_DIR=$DEV_DIR"/"$PROJECT_DIR

echo "Creating Sench Touch + PhoneGap App for Android:"
echo "SENCHA_SDK="$SENCHA_SDK
echo "SENCHA_CMD="$SENCHA_CMD
echo "PHONEGAP="$PHONEGAP
echo "-------------------"
echo "Project Name: " $PROJECT_NAME
echo "Package Name: " $PACKAGE_NAME
echo "Project Directory: " $APP_DIR

echo "Sencha Touch App..."
cd $SENCHA_SDK
pwd
$SENCHA_CMD/sencha generate app $PROJECT_NAME $APP_DIR
cp $PHONEGAP"/android/cordova-"$CORDOVA_VER".js" $APP_DIR
ls -al $APP_DIR

echo "PhoneGap App ..."
$PHONEGAP/android/bin/create $APP_DIR/build/$PROJECT_NAME/android $PACKAGE_NAME $PROJECT_NAME

Add these Ant build targets to the build.xml file:

   <target name="-after-build">
      <delete dir="${build.dir}/android/assets/www"/>
      <copy todir="${build.dir}/android/assets/www">
        <fileset dir="${build.dir}/package"/>
      </copy>
    </target>

Notes:
Sencha 2.2 had issues with Ruby 2.0 and I was getting Ant build errors (Compass failing).
I had to install GCC 4.2 which was no longer available in OSX Lion.

$ brew tap --repair homebrew/dupes
$ brew install apple-gcc42
$ export CC=/usr/local/bin/gcc-4.2
$ rvm pkg install readline
$ rvm install 1.9.3
$ gem update system
$ gem install compass

Run the build again:

$ sencha app build package && build/MyApp/android/cordova/debug

Leave a Reply

You must be logged in to post a comment.