Ionic Build Scripts

Posted on Updated on

I don’t like repetitive manual work, especially if can automate or script it.

In honour of that, these are my Ionic build scripts.

Enjoy.

 

Updated: 20200312

I’ve left all the rubbish workings out in there. Feel free to clean them up as required.

To make testing easier on Android, I upload them to Dropbox/Mega and then install them quickly on the device as a deployed test.

 

deploy_android.sh
node ./node_modules/node-sass/scripts/install.js

ionic cordova platform rm android
#ionic cordova platform add android

#cordova platform add android --save

ionic cordova platform add android@7.1.4
#https://forum.ionicframework.com/t/ionic-v1-android-ionic-cordova-platform-add-android/127543
ionic cordova build android --prod --release

#keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-alias

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.jks platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk my-alias
cp  ~/Library/Android/sdk/build-tools/28.0.3/zipalign platforms/android/app/build/outputs/apk/release/

cd platforms/android/app/build/outputs/apk/release/
rm c4israel_int.apk
./zipalign -v 4 app-release-unsigned.apk c4israel_int.apk

#copy to dropbox
#cp c4israel_int.apk /Volumes/Creative2HD/DropBox/Dropbox/c4i/c4israel_int_1.apk

# copy to MEGA
cp c4israel_int.apk /Volumes/Creative2HD/MEGASync/C4I/c4israel_int_1.apk


cd ..
cd ..
cd ..
cd ..
cd ..
cd ..
cd ..

 

deploy_ios.sh
# BUILDING FOR IOS

##################################
#
#     MAKE SURE YOU UNPLUG ALL DEVICES!!!!!
#
##################################

# Just in case.
node ./node_modules/node-sass/scripts/install.js

ionic cordova platform remove ios
ionic cordova platform add ios
#ionic cordova platform update ios@3.9.2      #not sure which is best yet... # really old
#ionic cordova platform update ios@3.20.0    #not sure which is best yet...
#ionic cordova platform update ios@4.5.4    #not sure which is best yet...

# --buildFlag="-UseModernBuildSystem=0" is used for onsignal workaround
# https://github.com/apache/cordova-ios/issues/407

npm install -g ios-deploy
#npm install -g ios-deploy --save
#npm install ios-deploy@1.9.2 --save


#sudo gem install cocoapods
cd platforms
cd ios
pod install
#pod repo update
cd ..
cd ..

#ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0" # worked...

#ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0" # worked...
#ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0" 
ionic cordova build ios --prod --release --buildFlag="-UseModernBuildSystem=0" --verbose

# --prod
#ionic cordova build ios --prod --buildFlag="-UseModernBuildSystem=0"

cd platforms
cd ios

pod install
#pod repo update

open "APPNAME.xcworkspace/"

open /Users/PATH/ionicApps/APPNAME/platforms/ios/APPNAME.xcworkspace/


#open APPNAME.xcodeproj/
cd ..
cd ..

 

emulator.sh
ionic cordova platform remove android
ionic cordova platform add android@6.4.0 
ionic cordova build android
ionic cordova run android --no-native-run

 

run_android.sh
ionic cordova run android --device

 

 

 

OLDER VERSIONs:

deploy_android.sh

ionic cordova platform rm android
ionic cordova platform add android@6.4.0
ionic cordova build android --prod --release --debug

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.jks platforms/android/build/outputs/apk/release/android-release-unsigned.apk my-alias

cp ~/Library/Android/sdk/build-tools/27.0.3/zipalign platforms/android/build/outputs/apk/release/

cd platforms/android/build/outputs/apk/release/
rm app_name.apk
./zipalign -v 4 android-release-unsigned.apk app_name.apk

# copy to MEGA
cp app_name.apk /Volumes/Creative2HD/MEGASync/C4I/app_name_1.apk

cd ..
cd ..
cd ..
cd ..
cd ..
cd ..
cd ..

deploy_ios.sh

ionic cordova platform remove ios
ionic cordova platform add ios

cd platforms
cd ios
pod install
cd ..
cd ..

ionic cordova build ios --prod --release --buildFlag="-UseModernBuildSystem=0"

cd platforms
cd ios

pod install
pod repo update

open "APP_NAME.xcworkspace"

cd ..
cd ..

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s