Skip to content

Instantly share code, notes, and snippets.

@haysclark
Last active January 21, 2016 19:22
Show Gist options
  • Save haysclark/7728758 to your computer and use it in GitHub Desktop.
Save haysclark/7728758 to your computer and use it in GitHub Desktop.
Script generates an IPA file from the default OpenFL iOS build path. Has various options, use -h to get help.
#!/bin/bash
#
# OpenFL Build to IPA Script iOS 2.0, 2014
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Written by Hays Clark <[email protected]>
#
# Latest version can be found at https://gist.github.com/haysclark/
# Tested on OSX (10.9) with XCode 5.1.1
#
# Copyright (c) 2014 Hays Clark
#
NAME="build_ipa"
VERSION=2.0
OPEN_DIR=0
VERBOSE=0
APP_NAME=""
BUILD_DIR=""
SIGN=""
EMBED=""
EXPECTED_FLAGS="[-v] [-h] [-a] [-s sign] [-e embed] [-b builddir] [-o outputfile]"
while getopts "vhazb:i:o:s:e:d:" VALUE "$@" ; do
if [ "$VALUE" = "h" ] ; then
echo usage: $NAME $EXPECTED_FLAGS
echo
echo "Options"
echo " -v verbose"
echo " -a auto-open the output folder on complete"
echo " -o set the output name of IPA instead of build filename"
echo " -s set signing profile. Example: iPhone Distribution: Company Name"
echo " -e set provisioning profile. Example: ProvProfile.mobileprovision"
echo " -b set location of ios build instead of default OpenFl dir"
echo "(-h) show this help"
exit 0
fi
if [ "$VALUE" = "v" ] ; then
echo $NAME version $VERSION
VERBOSE=1
fi
if [ "$VALUE" = "a" ] ; then
OPEN_DIR=1
fi
if [ "$VALUE" = "o" ] ; then
IPA_PATH="$OPTARG"
fi
if [ "$VALUE" = "s" ] ; then
SIGN="$OPTARG"
fi
if [ "$VALUE" = "e" ] ; then
EMBED="$OPTARG"
fi
if [ "$VALUE" = "b" ] ; then
BUILD_DIR="$OPTARG"
fi
if [ "$VALUE" = ":" ] ; then
echo "Flag -$OPTARG requires an argument."
echo "Usage: $0 $EXPECTED_FLAGS"
exit 1
fi
if [ "$VALUE" = "?" ] ; then
echo "Unknown flag -$OPTARG detected."
echo "Usage: $0 $EXPECTED_FLAGS"
exit 1
fi
done
if [ "$BUILD_DIR" = "" ]; then
BUILD_DIR="Export/ios/build/Release-iphoneos/"
fi
if [ ! -d "$BUILD_DIR" ]; then
echo $BUILD_DIR" does not exist! Please build project or supply ios build directory."
echo " -try \"openfl build ios\" first"
exit 1;
fi
if [ "$APP_NAME" = "" ]; then
#is there a better way?
APP_FILE=$(find $BUILD_DIR -type f | grep -o '.*app' | head -1)
APP_BASENAME=$(basename $APP_FILE)
APP_NAME=${APP_BASENAME%.*}
fi
if [ "$IPA_PATH" = "" ]; then
IPA_PATH=$APP_NAME.ipa
fi
echo "Building" "$IPA_PATH"
FULL_IPA_PATH=`pwd`/"$IPA_PATH";
SIGN_FLAG=""
if [ "$SIGN" = "" ]; then
SIGN_FLAG="--sign" $SIGN
fi
EMBED_FLAG=""
if [ "$EMBED" = "" ]; then
EMBED_FLAG="--sign" $EMBED
fi
VERBOSE_FLAG=""
if [ "$VERBOSE" -eq 1 ]; then
VERBOSE_FLAG="-verbose"
fi
xcrun -sdk iphoneos PackageApplication \
${APP_FILE} \
-o ${FULL_IPA_PATH} \
$SIGN_FLAG \
$EMBED_FLAG \
$VERBOSE_FLAG
if [ "$OPEN_DIR" -eq 1 ]; then
open .
fi
@player-03
Copy link

I think lines 111 and 116 should have != instead of =. Also, I think line 117 should have --embed instead of --sign.

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