Skip to content

Instantly share code, notes, and snippets.

@paristote
Created October 7, 2015 04:03
Show Gist options
  • Save paristote/24f11ab8335cfd9991bb to your computer and use it in GitHub Desktop.
Save paristote/24f11ab8335cfd9991bb to your computer and use it in GitHub Desktop.
Build and generate an IPA of the specified iOS project
#!/bin/bash
WORKSPACE=""
SCHEME=""
DESTINATION=""
PROV_PROFILE=""
usage(){
echo "Usage: "`basename "$PRG"`" [options]"
echo ""
echo " Build and generate an IPA of the project"
echo ""
echo "options:"
echo ""
echo " --workspace <workspace file> The xcworkspace file to build"
echo " --scheme <scheme name> The scheme to build"
echo " --path <destination path> The path where the ipa will be generated"
echo " --profile <profile name> The provisioning profile name"
exit 1
}
while [ "$1" != "" ]; do
case $1 in
--workspace )
# Error if no workspace provided
if [ $# -lt 2 ]
then
echo "Missing value for option --workspace"
echo ""
usage
exit
fi
shift
WORKSPACE=$1
;;
--scheme )
# Error if no scheme provided
if [ $# -lt 2 ]
then
echo "Missing value for option --scheme"
echo ""
usage
exit
fi
shift
SCHEME=$1
;;
--path )
# Error if no path provided
if [ $# -lt 2 ]
then
echo "Missing value for option --path"
echo ""
usage
exit
fi
shift
DESTINATION=$1
;;
--profile )
# Error if no profile provided
if [ $# -lt 2 ]
then
echo "Missing value for option --profile"
echo ""
usage
exit
fi
shift
PROV_PROFILE=$1
;;
esac
shift
done
xcodebuild clean -workspace $WORKSPACE -scheme $SCHEME
xcodebuild archive -workspace $WORKSPACE -scheme $SCHEME -archivePath $DESTINATION/$SCHEME.xcarchive
xcodebuild -exportArchive -archivePath $DESTINATION/$SCHEME.xcarchive/ -exportPath $DESTINATION/$SCHEME.ipa -exportFormat ipa -exportProvisioningProfile $PROV_PROFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment