Skip to main content

Getting started with Ionic/Cordova apps

Abstract

Get started on Bitrise by signing up via email or a Git provider, connecting a repository, and running the first build for your Ionic/Cordova app.

You can use Cordova and Ionic frameworks to develop cross-platform apps. Bitrise can help you with its automated testing, code signing and deployment procedures so that you can ship your iOS and/or Android app/s to the respective marketplace in no time! If your Workspace has more than one concurrency, you can have Android and iOS builds run simultaneously. Now let us guide you through the process!

Do you have a Bitrise account?

Make sure you have signed up to bitrise.io and can access your Bitrise account. There are multiple ways of registering an account:

Adding an Ionic/Cordova app to Bitrise

Wait while Bitrise is validating your project. We look for your configuration files and set up your app based on them.

  1. Go to your Bitrise Dashboard.

  2. Click the + sign on the top menu bar and select Add New App on web UI, which takes you to the Create New App page.

    Alternatively, you can add your app using a CLI. For more details, check out Adding a new app from a CLI.

  3. Choose the account you wish to add the app to.

  4. Set the privacy of the app to either Private or Public and click Next.

  5. Select the Git hosting service that hosts your repository, then find and select your own repository that hosts the project.

  6. When prompted to set up repository access, click No, auto-add SSH key.

  7. Type the name of the branch that includes your project’s configuration - main, for example, - then click Next.

  8. At Project Build configuration, you can select which platform to build your app for. You can select:

    • iOS.

    • Android.

    • iOS and Android (where the Android build gets built first).

    Getting started with Ionic/Cordova apps
    Getting started with Ionic/Cordova apps
  9. Register a webhook when prompted so that Bitrise can start a build automatically when code is pushed to your repository.

    This also kicks off your first build on the primary Workflow - click the message and it will take you to the build page. The first build does not generate an .apk and an .ipa yet, however, you can already check out the project’s logs on the build’s page.

Installing dependencies for Ionic/Cordova apps

If the Bitrise project scanner has successfully scanned your Ionic/Cordova project, Run npm command or Run yarn command Steps will be included in your default Workflows. These Steps can install the missing Javascript dependencies for your app.

For native Android dependencies, you can use the Install missing Android SDK components Step.

For native iOS dependencies, you can use, among others, the Brew install Step or the Run CocoaPods install Step.

To install Javascript dependencies with npm:

Using Yarn instead of npm

In this guide, we're using npm to install Javascript dependencies. However, you can use the Run yarn command Step: it can install missing JS dependencies without any additional configuration required.

  1. Open your app on Bitrise.

  2. Click the Workflows button on the main page.

  3. Select a Workflow from the WORKFLOW dropdown menu.

    Installing any additional tools
  4. Make sure your Workflow includes the Run npm command Step.

  5. In The 'npm' command with arguments to run input variable, type install.

    Getting started with React Native apps

    Using the npm ci command instead of npm install

    If you already have an up to date package-lock.json file in your project, we recommend using the ci command in The 'npm' command with arguments to run input. Using npm ci can not only result in much faster build times compared to npm install but more reliable builds as well.

Testing Ionic/Cordova apps

You can run unit tests for Ionic/Cordova apps on Bitrise by using our Karma Jasmine Test Runner or Jasmine Test Runner Steps.

If your Cordova/Ionic project has a Karma Jasmine dependency in its package.json file, our scanner will detect it when you're adding your app and automatically insert the respective testing Step into your Workflow. If this dependency is missing from your project, you can manually insert one of our testing steps to your Workflow using our Workflow Editor.

  1. Open your app on Bitrise.

  2. Click the Workflows button on the main page.

    opening-workflow-editor.png
  3. Make sure you have a testing Step in your Workflow.

    Important

    During the build process, your dependencies must be installed before you could run tests.

    You can choose between the Karma Jasmine Test Runner and the Jasmine Test Runner Steps.

Example 1. Cordova app configuration with Karma Jasmine Test Runner

In this example, you can find a bitrise.yml configuration that includes a Workflow called primary. This Workflow includes the Karma Jasmine Test Runner Step.

primary:
    steps:
    - activate-ssh-key@4.0.3:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.11: {}
    - script@1.1.5:
        title: Do anything with Script step
    - npm@0.9.1:
        inputs:
        - command: install
    - karma-jasmine-runner@0.9.1: {}
    - deploy-to-bitrise-io@1.3.15: {}

Code signing Ionic/Cordova apps

If you want to build an app for iOS or Android, you need to upload the platform-specific files into the Code Signing tab of the Workflow Editor. You can also generate builds for both platforms which requires uploading all code signing files of the platforms.

iOS code signing for Ionic and Cordova projects

Abstract

Bitrise supports both manual and automatic provisioning for the iOS code signing of Ionic and Cordova apps as well.

Naturally, Bitrise supports iOS applications built with either Ionic or Cordova. However, the code signing process is slightly different compared to a native Xcode project.

Bitrise supports both manual and automatic provisioning for Ionic and Cordova apps as well - and once again, the processes are somewhat different.

Ionic/Cordova code signing with manual code signing asset management

  1. Generate the native Xcode project locally from your Ionic or Cordova project by calling cordova platform add ios or ionic cordova platform add ios.

  2. Use our codesigndoc tool to collect the code signing files.

  3. Upload the files to bitrise.io.

    You can do this either on the website UI or with the codesigndoc tool itself.

    Uploading certificates and Provisioning Profiles
  4. Make sure you have the Certificate and profile installer Step in your Workflow.

  5. Add the Generate cordova build configuration Step to your Workflow. It must come after the Certificate and profile installer Step.

  6. Fill in the required inputs for the Step. Please note that both the Code Signing Identity and the Provisioning Profile are required inputs for iOS apps even though they are not marked as such.

    • Build configuration: you can set it to either debug or release.

    • Code Sign Identity: enter a Developer or a Distribution identity.

    • Provisioning Profile: enter the appropriate provisioning profile.

    • Packaging Type: this controls what type of build is generated by Xcode. Set the type of code signing you need.

      Code signing with Ionic and Cordova projects
  7. Add the Cordova archive or the Ionic archive step to your workflow.

  8. Fill in the required inputs.

    • The Platform input needs to be set to: device.

    • The Build command configuration input must match the Build configuration input of the Generate cordova build configuration Step.

    This Step must come after the Generate cordova build configuration Step in the Workflow.

  9. Run your build!

Ionic/Cordova code signing with automatic code signing asset management

  1. Make sure your .p12 signing certificates are uploaded to bitrise.io.

    If you use codesigndoc to collect the files, note that you can tell the tool to export only the certificates, by calling:

    codesigndoc scan --certs-only xcode  

    codesigndoc can also upload the files to the website, or you can do that manually.

  2. Add the Cordova prepare or the Ionic prepare Step to your Workflow. These Steps call the platform rm and platform add commands.

  3. Add the Manage iOS Code Signing Step to your Workflow. If you have both the Certificate and Profile Installer and the Manage iOS Code Signing Steps in your Workflow, your build might encounter unexpected issues.

    The Step will export:

    • The project’s development team.

    • The installed codesign identity’s name.

    • The installed provisioning profile.

    One code signing Step only

    If you have both the Certificate and profile installer and the Manage iOS Code Signing Steps in your Workflow, your build might encounter unexpected issues.

  4. Select the Apple service connection method (based on the Apple service you have set up in Bitrise) and the Distribution method.

    manageioscodesigning.png
  5. Add the Generate cordova build configuration Step to your Workflow.

  6. Configure the Step to use the code signing settings exported by the Manage iOS Code Signing Step:

    Development distribution example:

    - generate-cordova-build-configuration:
        inputs:
        - development_team: $BITRISE_DEVELOPER_TEAM 
        - package_type: development 
        - code_sign_identity: iPhone Developer
        - configuration: debug
    

    Production distribution example:

    - generate-cordova-build-configuration:
        inputs:
        - development_team: $BITRISE_DEVELOPER_TEAM 
        - package_type: app-store 
        - code_sign_identity: iPhone Developer
        - configuration: release
    
  7. Add the Cordova Archive or the Ionic Archive Step to your Workflow.

  8. Fill in the required inputs.

    • The Platform input needs to be set to: device.

    • The Build command configuration input must match the Build configuration input of the Generate cordova build configuration Step.

      Code signing with Ionic and Cordova projects
  9. Set the Should remove platforms as prepare step? to false. This is crucial: it ensures the Step will not remove and re-add the platform of the native projects generated in the Cordova prepare or the Ionic prepare Step.

  10. Run your build!

Android code signing using the Android Sign Step

Abstract

You can create a signed APK using the Android Sign Step in your Bitrise Workflow. This Step is configured to run if you have already uploaded your keystore file on the Code signing tab of the Workflow Editor.

You can create a signed APK using the Android Sign Step in your Bitrise Workflow. This Step is configured to run if you have already uploaded your keystore file on the Code Signing tab of the Workflow Editor.

The Android Sign Step is not required if signing is configured in your project’s build.gradle file. If so, running the Android Build Step (or the Gradle Runner Step) signs the output (APK or AAB) automatically. Nevertheless, we recommend that you use the Android Sign Step to sign your project in an easy and secure way.

jarsign and apksigner

APKs can be signed with either jarsigner or apksigner. For APKs, if you wish to use apksigner to sign your project, then in the Android Sign Step you have to first set the Enables apksigner input to true and leave the APK Signature Scheme input on automatic. This way apksigner checks your APK’s minimum and target SDK versions and chooses the required schemes. It signs your project with V1 scheme if your minimum supported version is low and it also signs with other schemes for newer systems.

Please note that AAB files can only be signed with jarsigner. The Step uses jarsigner if it detects a file ending with .aab

  1. Open your app on Bitrise.

  2. Click the Workflows button on the main page.

    opening-workflow-editor.png
  3. Go to Code Signing > Android Code Signing.

  4. Drag-and-drop your keystore file to the Upload file field of the ANDROID KEYSTORE FILE section.

    A keystore URL automatically gets generated once you upload the keystore file. Bitrise assigns an Environment Variable (BITRISEIO_ANDROID_KEYSTORE_URL) to the download URL (which is a time-limited, read-only download URL) of the file as the value. No need to download it manually as the Android Sign Step downloads it automatically.

  5. Fill out the displayed three input fields with your credentials:

    • Keystore password

    • Keystore alias

    • Private key password

  6. Click Save metadata.

    When you have successfully uploaded a keystore file to the ANDROID KEYSTORE FILE section, Bitrise will automatically export the following Environment Variables based on your input:

    • $BITRISEIO_ANDROID_KEYSTORE_ALIAS

    • $BITRISEIO_ANDROID_KEYSTORE_PASSWORD

    • $BITRISEIO_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD

    • $BITRISEIO_ANDROID_KEYSTORE_URL

  7. Add the Android Sign Step to your Workflow after the Step that builds your APK or AAB file.

    Bitrise uses the above Environment Variables and sets them as inputs into the respective fields of the Android Sign Step. Once the Step runs, it produces either a signed APK or an AAB. The signed APK or AAB is used in deploy Steps, for example, the Google Play Deploy Step or the Deploy to Bitrise.io Step. The latter deploys the APK/AAB on the Artifacts tab. You can also use Ship to deploy your app once you built an APK/AAB file.

Downloading your keystore file

You can download your keystore file to the project directory from the ANDROID KEYSTORE FILE section using the File Downloader Step:

- file-downloader:
   inputs:
   - source: $BITRISEIO_ANDROID_KEYSTORE_URL
   - destination: "$HOME/keystores/my_keystore.jks" #native android#

After this Step, my_keystore.jks will be available at $HOME/keystores/my_keystore.jks.

Deploying Ionic/Cordova apps

To build and deploy an Ionic or Cordova app on Bitrise, you need to digitally sign both the Android and iOS project (if you're building both) and then use the Cordova Archive or the Ionic Archive Step to build the app before deploying it.

You can deploy the successfully built app to:

  • Online stores, such as the Google Play Store or Apple's App Store.

  • Bitrise.io: the generated binaries will be available on the Artifacts tab of the build's page. You can download them from there or share them with others via the public install page.

Deploying a cross-platform app to bitrise.io

The Deploy to bitrise.io Step uploads all the artifacts related to your build into the Artifacts tab on your Build’s page.

You can share the generated app file (APK for Android or an IPA file for iOS) with your team members using the public install page. The public install page is a URL you can share with others who can install the generated app binary on their device. You can also notify user groups or individual users that your APK or IPA file has been built.

  1. Open your app on Bitrise.

  2. Click the Workflows button on the main page.

  3. Select a Workflow from the WORKFLOW dropdown menu.

    Installing any additional tools
  4. Make sure you have the Deploy to bitrise.io Step in your Workflow.

  5. In the Notify: User Roles, add the role so that only those get notified who have been granted with this role. Or fill out the Notify: Emails field with email addresses of the users you want to notify.

    Make sure you set those email addresses as Secrets! These details can be also modified under Notifications if you click the eye icon next to your generated binary in the Artifacts tab.

  6. If you want the Step to generate a public install page for you, set the Enable public page for the App? input to true.

Deploying your Android project to Google Play

You can use the Deploy to Google Play Step in your Workflow to upload your digitally signed AAB/APK to the Google Play Store.

  1. Add the Cordova archive or the Ionic archive Step to your Workflow.

    Note that if you’re building for both iOS and Android in one project, and either of your apps fails, the whole Cordova archive/Ionic archive Step will fail.

  2. Fill in the required inputs.

    • The Platform input needs to be set to device.

    • The Build command configuration input must match the Build configuration input of the Generate cordova build configuration Step.

    The archive Step must come after the Generate cordova build configuration Step in the Workflow.

  3. Configure code signing for your app.

  4. Configure Google Play access.

    You only need to do this for your very first Google Play deployment of the app.

  5. Make sure you have the Deploy to Google Play Step after the Cordova Archive or Ionic Archive Step in your Workflow.

  6. Fill out the required input fields as follows:

    • Service Account JSON key file path: This field can accept a remote URL so you have to provide the Env Var which contains your uploaded service account JSON key. For example: $BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL.

    • Package name: The package name of your Android app.

    • Track: The track where you want to deploy your APK (for example, alpha/beta/rollout/production or any custom track you set).

Deploying your iOS project to the App Store

  1. Add the Cordova archive or the Ionic archive Step to your Workflow.

    Note that if you’re building for both iOS and Android in one project, and either of your apps fails, the whole Cordova archive/Ionic archive Step will fail.

  2. Fill in the required inputs.

    • The Platform input needs to be set to device.

    • The Build command configuration input must match the Build configuration input of the Generate cordova build configuration Step.

    The archive Step must come after the Generate cordova build configuration Step in the Workflow.

  3. Configure iOS code signing for your iOS project.

  4. Add the Deploy to App Store Connect - Application Loader (formerly iTunes Connect) Step to your Workflow, after the Xcode Archive & Export for iOS Step but preferably before the Deploy to Bitrise.io Step.

  5. Provide your Apple credentials in the Deploy to App Store Connect - Application Loader (formerly iTunes Connect) Step.

    The Step will need your:

    • Apple ID.

    • Password or, if you use two-factor authentication on App Store Connect, your application password.

    Don’t worry, the password will not be visible in the logs or exposed.

  6. Start a build.