Last active
March 7, 2018 13:51
-
-
Save EarMaster/ec0789d84bfa20fd4c81ddededb4e049 to your computer and use it in GitHub Desktop.
CLI function to build old versions of Titanium and automatically select according XCode and npm versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function build-titanium() { | |
if [ ! -f tiapp.xml ]; then | |
echo "File tiapp.xml not found." | |
else | |
echo "Parsing tiapp.xml." | |
outputDir="./dist" | |
oldNodeVersion=$(node -v | sed "s/v//") | |
buildAndroid=$(grep -c "<target device=\"android\">true</target>" tiapp.xml) | |
buildiPad=$(grep -c "<target device=\"ipad\">true</target>" tiapp.xml) | |
buildiPhone=$(grep -c "<target device=\"iphone\">true</target>" tiapp.xml) | |
sdkVersion=$(grep "<sdk-version>" tiapp.xml | sed "s/<sdk-version>//" | sed "s/<\/sdk-version>//" | tr '\r' ' ' | tr '\n' ' ' | xargs) | |
nodeVersion="node" | |
oldXcode=false | |
if [ $sdkVersion == "7.0.2.GA" ]; then | |
nodeVersion="8.6.0" | |
elif [ $sdkVersion == "6.3.0.GA" ]; then | |
nodeVersion="6.12.0" | |
elif [ $sdkVersion == "6.2.2.GA" ]; then | |
nodeVersion="6.12.0" | |
elif [ $sdkVersion == "5.5.1.GA" ]; then | |
nodeVersion="5.12.0" | |
#oldXcode=true | |
elif [ $sdkVersion == "5.2.2.GA" ]; then | |
nodeVersion="5.1.1" | |
oldXcode=true | |
elif [ $sdkVersion == "5.1.2.GA" ]; then | |
nodeVersion="5.1.1" | |
oldXcode=true | |
elif [ $sdkVersion == "4.1.0.GA" ]; then | |
nodeVersion="5.1.1" | |
oldXcode=true | |
elif [ $sdkVersion == "4.0.0.GA" ]; then | |
nodeVersion="5.1.1" | |
oldXcode=true | |
fi | |
echo "Switching node version ($nodeVersion) and Titanium SDK ($sdkVersion)." | |
nvm use node $nodeVersion | |
ti sdk select $sdkVersion | |
ti clean | |
if [ $buildiPad -gt 0 ] || [ $buildiPhone -gt 0 ]; then | |
if [ "$oldXcode" = true ]; then | |
echo "Switching XCode version (6.4)." | |
sudo xcode-select -s PATH_TO_XCODE_6_4 | |
fi | |
xcodebuild -version | |
echo "Building iOS." | |
ti build -p ios --target ? -O "$outputDir" | |
if [ "$oldXcode" = true ]; then | |
echo "Reseting XCode to latest version." | |
sudo xcode-select -r | |
fi | |
fi | |
if [ $buildAndroid -gt 0 ]; then | |
echo "Building Android." | |
keystorePath="DEFAULT_KEYSTORE_PATH" | |
keystorePassword="DEFAULT_KEYSTORE_PASSWORD" | |
if [ $1 ]; then | |
keystorePath="$1" | |
keystorePassword="$2" | |
fi | |
ti build -p android -K "$keystorePath" -P "$keystorePassword" -T dist-playstore -O "$outputDir" | |
fi | |
echo "Reseting node to previous version ($oldNodeVersion)." | |
nvm use node $oldNodeVersion | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment