Skip to content

Instantly share code, notes, and snippets.

@shaneparsons
Last active February 16, 2024 10:13
Show Gist options
  • Save shaneparsons/3ef86ddfcfb2559471ff566a506aafac to your computer and use it in GitHub Desktop.
Save shaneparsons/3ef86ddfcfb2559471ff566a506aafac to your computer and use it in GitHub Desktop.
Preparing for Release / Publishing an Ionic App

Preparing for Release / Publishing an Ionic App

Customizing Cordova's config.xml file

Go to your project root and open config.xml file in your text editor.

The first thing to change is your app's human readable name. Replace the name inside <name> </name>.

Second, change the id value inside

<widget id="com.ionicframework.app" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

to your reverse domain name. For example, id="com.thirtypointdesign.app". This is important. The id is the unique identifier when you publish your app on iOS or Android. In iOS, this will be your bundle ID. In Android, this will be your package name.

Third, if you are updating your app. Please change your version number to a higher value. If this is your first time publishing the app, you do not need to change that.

If you want your app only in portrait mode, you can add this line in the xml file as well:

<preference name="orientation" value="portrait" />

For more customization information, please visit Cordova Official Site

Android

Building and Signing your Android Release

You will need to build a digitally signed Android release APK file to distribute your app on Google Play Store or other app distribution channels. Note: You will need to pre-install Android SDK before moving to this step.

  1. Create your digital signed key (if you don't already have one).
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
  1. Add the Android Android platform.
ionic cordova platform add android
  1. Build a production / release version of your app. This will generate an android-release-unsigned.apk file under platforms/android/build/outputs/apk.
ionic cordova build android --prod --release
  1. Sign your release build apk.
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore android-release-unsigned.apk alias_name
  1. Align your build with the android zipalign tool. If you get a "command not found error", navigate to your android sdk folder, find the zipalign tool under build-tools / version number and drag the folder into your terminal to get the absolute path
[Your Android SDK path]/build-tools/[Newest version number]/zipalign -v 4 android-release-unsigned.apk [app-name].apk
/usr/local/Cellar/android-sdk/24.4.1_1/build-tools/27.0.3/zipalign -v 4

The newly made apk is the final signed apk file you need to upload onto Google Play Store or any other Android distribution networks.

Publish your app on Google Play Store.

Now that you have your release APK ready for Google Play, you can create a Play Store listing and upload your APK. To start, you'll need to visit the Google Play Store Developer Console and create a new developer account. It will cost $25.

Once you have a developer account, you can go ahead and click "Publish an Android App on Google Play" and follow the on-screen instructions.

iOS

Building and Signing your iOS Release

First, you'll need an Apple Developer account, They cost $99 /year. Once you're an Apple Developer, sign into the Apple Member Center and create an App ID (must match the one in config.xml), Certificate, and a Provisioning Profile. Once you have those in place:

  1. Add the iOS platform.
ionic cordova platform add ios
  1. Open the generated Xcode file and set your development team from the dropdown.
  2. Build a production version of your app.
ionic cordova build ios --prod
  1. If you now have a .xcarchive file in platforms/ios, open it in Xcode and skip to the very bottom. Otherwise continue to the next point.
  2. In Xcode, go to Product > Archive and archive your app for release. If you get a "check dependencies" error:
  • uncheck / disable automatic signing
  • re-check / enable automatic signing
  • run Product > Archive again

Publish your app on Apple App Store.

Click "Submit to App Store" to submit your app. Note: In order to submit your app, you'll need to create it from iTunes Connect.

@alexandruchirita4192
Copy link

alexandruchirita4192 commented Oct 11, 2023

I see that this Ionic Publishing uses Cordova, but it is deprecated by Microsoft:
"In April 2022, Microsoft App Center deprecated Cordova support, a true sign of the waning popularity of the framework".

Do you think the guide should be changed to use something else?

Source of the statement:
https://ionic.io/blog/signs-its-time-to-migrate-your-cordova-app

Guide to migrate from Cordova to Capacitor, if needed:
https://capacitorjs.com/docs/cordova/migrating-from-cordova-to-capacitor

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