-
-
Save dawsontoth/855554 to your computer and use it in GitHub Desktop.
Bash script to quickly simulate / emulate / deploy Appcelerator Titanium Mobile apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# This script helps you run Titanium Mobile apps from the command line. | |
# | |
# You will want to customize the variables on lines 25-37, per your own environment. | |
# Most important is to customize "appRootDirectory". | |
# | |
# It can be used a couple of different ways: | |
# 1) To start the Android emulator: | |
# ./t a | |
# 2) To start a simulator, emulator, or deploy to device, use the following: | |
# ./t myAppDirectory arg | |
# where "arg" is one of the following: | |
# - si: Launch iOS simulator | |
# - di: Deploy to attached iOS device (via iTunes) | |
# - sa: Launch app in already running Android emulator | |
# - da: Deploy to attached Android device | |
# - smw: Build for mobile web. | |
# - clean: Touches the tiapp.xml and copies a corresponding rm -Rf command to your clipboard to clean the build. | |
# So, for example, to run the iOS simulator for an app with the directory name "play": | |
# ./t play si | |
# | |
# That's it! Enjoy. | |
## | |
t="2.1.0" | |
appRootDirectory="/Volumes/Code" | |
androidsdk="/usr/android-sdk" | |
androidapi="APIs 2.2" | |
androidresolution="HVGA" | |
androidemulator="2.3.3BigSDCard" | |
iosversion="5.1" | |
iossimulator="iphone" | |
iosscheme="universal" | |
ioscertificate="A70000C0-E0F8-4000-901B-4C0004400010" | |
iosprofile="Dawson Toth (95B000R00S)" | |
## | |
# 2 passed in arguments means launch simulator or deploy; otherwise, show android package manager | |
## | |
if [ $# = 2 ] | |
then | |
## | |
# Find out the ID and name of your project from tiapp.xml | |
## | |
path="$appRootDirectory/$1" | |
id=`grep '<id>.*</id>' $path/tiapp.xml | cut -d '<' -f 2 | cut -d '>' -f 2` | |
name=`grep '<name>.*</name>' $path/tiapp.xml | cut -d '<' -f 2 | cut -d '>' -f 2` | |
if [ $2 = "sa" ] | |
then | |
/Library/Application\ Support/Titanium/mobilesdk/osx/$t/android/builder.py "simulator" "$name" "$androidsdk" "$path" "$id" "$androidapi" "$androidresolution" | |
adb -e logcat -c | |
adb -e logcat | |
exit | |
fi | |
if [ $2 = "da" ] | |
then | |
/Library/Application\ Support/Titanium/mobilesdk/osx/$t/android/builder.py "install" "$name" "$androidsdk" "$path" "$id" "7" | |
activity=`grep '<activity android:name="\.[^"]*"' $path/build/android/AndroidManifest.xml | cut -d '"' -f 2 | cut -d '"' -f 2` | |
#/usr/android-sdk/platform-tools/adb -d shell am start -n "$id/$activity" | |
#printf "from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice\ndevice = MonkeyRunner.waitForConnection()\ndevice.wake()\n\n" | /usr/android-sdk/tools/monkeyrunner | |
# got an unlock screen? try this in the monkeyrunning script: device.drag((240, 440), (240, 100), 2, 20) | |
exit | |
fi | |
if [ $2 = "si" ] | |
then | |
/Library/Application\ Support/Titanium/mobilesdk/osx/$t/iphone/builder.py "simulator" "$iosversion" "$path" "$id" "$name" "$iosscheme" "$iossimulator" "" | |
exit | |
fi | |
if [ $2 = "di" ] | |
then | |
/Library/Application\ Support/Titanium/mobilesdk/osx/$t/iphone/builder.py "install" "$iosversion" "$path" "$id" "$name" "$ioscertificate" "$iosprofile" "$iosscheme" | |
exit | |
fi | |
if [ $2 = "smw" ] | |
then | |
chmod +x /Library/Application\ Support/Titanium/mobilesdk/osx/$t/mobileweb/builder.py | |
/Library/Application\ Support/Titanium/mobilesdk/osx/$t/mobileweb/builder.py "$path" "development" | |
exit | |
fi | |
if [ $2 = "clean" ] | |
then | |
echo "rm -Rf $path/build/*/*" | pbcopy | |
touch "$path/tiapp.xml" | |
echo "rm -Rf copied to pasteboard" | |
exit | |
fi | |
fi | |
if [ $# = 1 ] | |
then | |
if [ $1 = "a" ] | |
then | |
$androidsdk/tools/emulator -avd "$androidemulator" -partition-size 2047 | |
exit | |
fi | |
fi | |
echo "Command not understood!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment