Deploying to iOS or Android

Since AIR 3.4, the SDK contains a very handy command line tool to copy the built packages (“ipa” for iPhone, “apk” for Android) to a device.

Here's a handy script that copies such a file to a connected device.

OS X

#!/bin/bash
 
# update these paths so that they point to the AIR SDK
adt="$HOME/Development/sdks/air_3.5/bin/adt"
adb="$HOME/Development/sdks/air_3.5/lib/android/bin/adb"
 
if [ ${1: -4} == ".ipa" ]
then
    "$adt" -installApp -platform ios -package $1
else
    "$adb" install -r $1
fi

Copy that code into a file named “deploy-to-device.sh”, and make it executable:

chmod u+x deploy-to-device.sh

That's it! Now you can use the script to copy an application package to a connected device. The script figures out if it's an Android or iPhone package, and calls the suitable program.

./deploy-to-device game.apk
./deploy-to-device game.ipa

Windows

I make no claims about my proficiency in .bat file creation, but this should do the trick (and seems to work fine for me)

Make a new file in your AIR SDK\bin folder called deploy-to-device.bat ex:

C:\Program Files\Adobe\Adobe Flash Builder 4.7 (64 Bit)\eclipse\plugins\com.adobe.flash.compiler_4.7.0.349722\AIRSDK\bin\deploy-to-device.bat

and add these lines to it:

@echo off
:: Get extension
setlocal ENABLEDELAYEDEXPANSION
set t=%1
set ext=!t:~-3!

if %ext% == ipa goto apple
if %ext% == apk goto android
goto end

:android
echo Installing on Android
..\lib\android\bin\adb.exe install -r %1
goto end

:apple
echo Installing on iOS
adt.bat -installApp -platform ios -package %1
goto end

:end

Now add the location of that file to your PATH environment variable, and you should be able to execute it from any directory. Alternatively, you can define the path to your SDK IN the file similar to the mac example, but I like having the tools all in one place.

The syntax would be the same as above:

deploy-to-device.bat app.apk
deploy-to-device.bat app.ipa
  tutorials/deploying_to_ios_and_android.txt · Last modified: 2014/10/24 01:39 by idlebishop
 
Powered by DokuWiki