Skip to content

Instantly share code, notes, and snippets.

@ryanhanwu
Last active July 28, 2023 23:36
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ryanhanwu/11164353 to your computer and use it in GitHub Desktop.
Save ryanhanwu/11164353 to your computer and use it in GitHub Desktop.
My iOS IPA build script for XCode workspace with CocoaPods installed
#Code Sign
PRODUCT_NAME="MyApp"
WORKSPACE_NAME=$PRODUCT_NAME
SCHEME_NAME=$PRODUCT_NAME
DEVELOPER_NAME="iPhone Developer: XXXXXXXX (2CA66F8Y8L)"
PROVISONNING_PROFILE_DEBUG="profile/OOO.mobileprovision"
PROVISONNING_PROFILE_RELEASE="profile/XXXXX.mobileprovision"
#
BUILD_SDK="iphoneos"
BUILD_FOLDER="build"
DERIVEDDATA_FOLDER="derivedData"
#!/bin/sh
# Created by : Ryan Wu @ryanhanwu
# MIT License : http://ryanwu.mit-license.org
# set -x
#
CONFIG=build.config
if [ ! -f $CONFIG ]; then
echo "Configuration File not found!"
exit 0
fi
echo Importing Configuration
source $CONFIG
BUILD_NUMBER=`date +%m%d%H%M`
BUILD_DATE=`date +%m%d`
PROJ_DIR=`pwd`
DERIVEDDATA_PATH="${PROJ_DIR}/${DERIVEDDATA_FOLDER}"
BUILD_PATH="${PROJ_DIR}/${BUILD_FOLDER}"
function errorLeave {
echo "Command Usage :"
echo "\t > build.sh [ Debug | Release ] expected \n"
echo "Configuration File:"
echo "\t build.config"
exit 0
}
if [ "$1" = "Debug" ];then
XCONF="Debug"
XPROFILE=$PROVISONNING_PROFILE_DEBUG
elif [ "$1" = "Release" ];then
XCONF="Release"
XPROFILE=$PROVISONNING_PROFILE_RELEASE
else
errorLeave
fi
# echo Updating CocoaPods
# pod install
[ -d $DERIVEDDATA_PATH ] || mkdir -p $DERIVEDDATA_PATH
[ -d $BUILD_PATH ] || mkdir -p $BUILD_PATH
echo Building Workspace
xcodebuild -workspace "${WORKSPACE_NAME}.xcworkspace" -scheme $SCHEME_NAME -derivedDataPath $DERIVEDDATA_PATH -configuration $XCONF
echo Verify Code Sign
codesign -d -vvv --file-list - "${DERIVEDDATA_PATH}/Build/Products/${XCONF}-${BUILD_SDK}/${PRODUCT_NAME}.app"
echo Packaging IPA
xcrun -l -sdk $BUILD_SDK PackageApplication -v "${DERIVEDDATA_PATH}/Build/Products/${XCONF}-${BUILD_SDK}/${PRODUCT_NAME}.app" -o "${BUILD_PATH}/${PRODUCT_NAME}-${XCONF}-${BUILD_NUMBER}.ipa" –sign $DEVELOPER_NAME –embed $XPROFILE
open build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment