Command line (.sh) packaging AIR mobile app

Hey all,

I’m trying to put together a script which allows packaging of mobile AIR apps on Mac.

The latest error I’m getting is: line 205: [ios: command not found

I’d imagine there is more than one issue with this script as it’s so new to me so any help would be great.

My script so far (keep in mind I’ve never written Shell Script until today):

#!/bin/bash

### START EDITS ###

### IOS ###
ios_platform=ios
ios_test_interpreter_target=ipa-test-interpreter
ios_debug_interpreter_target=ipa-debug-interpreter
ios_test_target=ipa-test
ios_debug_target=ipa-debug
ios_ad_hoc_target=ipa-ad-hoc
ios_app_store_target=ipa-app-store
ios_development_certificate=certificates/Development_Certificate.p12
ios_distribution_certificate=certificates/Distribution_Certificate.p12
ios_development_password=password
ios_distribution_password=password

ios_development_provisional_profile=certificates/App_Development.mobileprovision
ios_distribution_provisional_profile=certificates/App_Distribution.mobileprovision
ios_ipa=app.ipa
ios_development_manifest=manifests/iOSApp-app.xml
ios_distribution_manifest=manifests/iOSApp_Distribution-app.xml
ios_swf_name=app.swf
ios_bundle_id=uk.co.**********.app

### ANDROID ###
android_platform=android
android_target=apk
android_debug_target=apk-debug
android_captive_runtime_target=apk-captive-runtime
android_certificate=certificates/Android-Certificates.p12
android_password=password

android_apk=app.apk
android_manifest=manifests/AndroidApp-app.xml
android_swf_name=app.swf
android_bundle_id=uk.co.**********.app

### END EDITS ###


### Export variables ###
export airsdk=../../AIR_SDK/AIR16.0/bin/adt
export target=null
export certificate=null
export password=null
export provisionalprofile=null
export filename=null
export manifest=null
export swfname=null
export platform=null
export bundleid=null


### Allow permissions ###
chmod +x ./commands/compile_ipa.sh
chmod +x ./commands/compile_apk.sh
chmod +x ./commands/remove_from_device.sh
chmod +x ./commands/push_to_device.sh


### Target Selection ###
echo ""
echo "Package App Target"
echo ""
echo "iOS:"
echo ""
echo "[1] fast test (ipa-test-interpreter)"
echo "[2] fast debug (ipa-debug-interpreter)"
echo "[3] slow test (ipa-test)"
echo "[4] slow debug (ipa-debug)"
echo "[5] ad-hoc (ipa-ah-hoc)"
echo "[6] app store (ipa-app-store)"
echo ""
echo "Android:"
echo ""
echo "[7] normal (apk)"
echo "[8] debug (apk-debug)"
echo "[9] captive runtime (apk-captive-runtime)"
echo ""
echo "[0] Exit"
echo ""
echo -n "Target: "
echo ""

while :
do
read targetselection
case $targetselection in
    1 ) target="$ios_test_interpreter_target";
        certificate="$ios_development_certificate";
        password="$ios_development_password";
        provisionalprofile="$ios_development_provisional_profile";
        filename="$ios_ipa";
        manifest="$ios_development_manifest";
        swfname="$ios_swf_name";
        platform="$ios_platform";
        bundleid="$ios_bundle_id"
        break
        ;;

    2 ) target="$ios_debug_interpreter_target";
        certificate="$ios_development_certificate";
        password="$ios_development_password";
        provisionalprofile="$ios_development_provisional_profile";
        filename="$ios_ipa";
        manifest="$ios_development_manifest";
        swfname="$ios_swf_name";
        platform="$ios_platform";
        bundleid="$ios_bundle_id"
        break
        ;;

    3 ) target="$ios_test_target";
        certificate="$ios_development_certificate";
        password="$ios_development_password";
        provisionalprofile="$ios_development_provisional_profile";
        filename="$ios_ipa";
        manifest="$ios_development_manifest";
        swfname="$ios_swf_name";
        platform="$ios_platform";
        bundleid="$ios_bundle_id"
        break
        ;;

    4 ) target="$ios_debug_target";
        certificate="$ios_development_certificate";
        password="$ios_development_password";
        provisionalprofile="$ios_development_provisional_profile";
        filename="$ios_ipa";
        manifest="$ios_development_manifest";
        swfname="$ios_swf_name";
        platform="$ios_platform";
        bundleid="$ios_bundle_id"
        break
        ;;

    5 ) target="$ios_ad_hoc_target";
        certificate="$ios_adhoc_certificate";
        password="$ios_adhoc_password";
        provisionalprofile="$ios_adhoc_provisional_profile";
        filename="$ios_ipa";
        manifest="$ios_development_manifest";
        swfname="$ios_swf_name";
        platform="$ios_platform";
        bundleid="$ios_bundle_id";
        bash ./commands/compile_ipa.sh;
        exit ;;

    6 ) target="$ios_app_store_target";
        certificate="$ios_distribution_certificate";
        password="$ios_distribution_password";
        provisionalprofile="$ios_distribution_provisional_profile";
        filename="$ios_ipa";
        manifest="$ios_distribution_manifest";
        swfname="$ios_swf_name";
        platform="$ios_platform";
        bundleid="$ios_bundle_id";
        bash ./commands/compile_ipa.sh;
        exit ;;

    7 ) target="$apk_target";
        certificate="$android_certificate";
        password="$android_password";
        provisionalprofile=null;
        filename="$android_apk";
        manifest="$android_manifest";
        swfname="$android_swf_name";
        platform="$android_platform";
        bundleid="$android_bundle_id"
        break
        ;;

    8 ) target="$apk_debug_target";
        certificate="$android_certificate";
        password="$android_password";
        provisionalprofile=null;
        filename="$android_apk";
        manifest="$android_manifest";
        swfname="$android_swf_name";
        platform="$android_platform";
        bundleid="$android_bundle_id"
        break
        ;;

    9 ) target="$android_captive_runtime_target";
        certificate="$android_certificate";
        password="$android_password";
        provisionalprofile=null;
        filename="$android_apk";
        manifest="$android_manifest";
        swfname="$android_swf_name";
        platform="$android_platform";
        bundleid="$android_bundle_id"
        break
        ;;

    0 ) exit ;;
esac
done

compile()
{
    if ["$platform" = "$ios_platform"]
    then
        bash ./commands/compile_ipa.sh
    else
        bash ./commands/compile_apk.sh
    fi
}

compileremovepush()
{
if ["$platform" = "$ios_platform"]
    then
        bash ./commands/compile_ipa.sh
    else
        bash ./commands/compile_apk.sh
    fi
    
    bash ./commands/remove_from_device.sh
    bash ./commands/push_to_device.sh
}

removepush()
{
    bash ./commands/remove_from_device.sh
    bash ./commands/push_to_device.sh
}

### Action Selection ###
echo ""
echo "Package App Action"
echo ""
echo "[1] Compile"
echo "[2] Compile/Remove/Push"
echo "[3] Remove/Push"
echo ""
echo "[0] Exit"
echo ""
echo -n "Action: "
echo ""

while :
do
read actionselection
case $actionselection in
    1 ) compile
        break
        ;;
        
    2 ) compileremovepush
        break
        ;;
        
    3 ) removepush
        break
        ;;
        
    0 ) exit ;;
esac
done

For anyone that had this problem, the issue is with the if statements …

if ["$platform" = "$ios_platform"]

should be

if [ "$platform" = "$ios_platform" ]

with Shell Script the space between the square brackets seems to matter.

1 Like

If anyone else is having difficulties with command line compiling of Adobe AIR apps for Android or iOS using either Windows or Mac I have put together a GitHub project containing all the .sh/.bat files. Hope this helps someone. https://github.com/antbirch1990/AIR-Command-Line-Packager-Windows-Mac