/fastlane-plugin-ionic

Integrate your Ionic build into your Fastlane setup

Primary LanguageRubyMIT LicenseMIT

fastlane Plugin for Ionic CLI

fastlane Plugin Badge License Gem

This fastlane plugin helps you build your Ionic Cordova project via the ionic CLI.

It is based on fastlane-plugin-cordova (where it borrows a lot of its code. Thanks!).

Getting Started

This project is a fastlane plugin. To get started with fastlane-plugin-ionic, add it to your project by running:

fastlane add_plugin ionic

Actions

ionic

Runs ionic cordova build (technically: ionic cordova prepare first, then ionic cordova compile [which is the same as what build does internally]) to build your Ionic project.

ionic(
  platform: 'ios', # Build your iOS Ionic project
)
ionic(
  platform: 'android', # Build your Android Ionic project
  release: false # Build a "Debug" app
)

Examples

Lanes using these actions could look like this:

platform :ios do
  desc "Deploy ios app on the appstore"

  lane :deploy do
    match(type: "appstore")
    ionic(platform: 'ios')
    deliver(ipa: ENV['CORDOVA_IOS_RELEASE_BUILD_PATH'])
  end
end

platform :android do
  desc "Deploy android app on play store"

  lane :deploy do
    ionic(
      platform: 'android',
      keystore_path: './prod.keystore',
      keystore_alias: 'prod',
      keystore_password: 'password'
    )
    supply(apk: ENV['CORDOVA_ANDROID_RELEASE_BUILD_PATH'])
  end
end

with an Appfile such as

app_identifier "com.awesome.app"
apple_id "apple@id.com"
team_id "28323HT"

The ENV['CORDOVA_ANDROID_RELEASE_BUILD_PATH'] is only valid for cordova-android 7.x and newer (which you should be using anyway!).

If you're using Crosswalk (which oyu should not really be doing anymore), replace supply(apk: ENV['CORDOVA_ANDROID_RELEASE_BUILD_PATH']) (and equivalents) by:

supply(
  apk_paths: [
   'platforms/android/build/outputs/apk/android-armv7-release.apk',
   'platforms/android/build/outputs/apk/android-x86-release.apk'
  ],
)

Plugin API

To check what's available in the plugin, install it in a project and run at the root of the project:

fastlane actions ionic

Which will produce:

Key Description Env Var Default
platform Platform to build on.
Should be either android or ios
CORDOVA_PLATFORM
release Build for release if true,
or for debug if false
CORDOVA_RELEASE true
device Build for device CORDOVA_DEVICE true
prod Build for production IONIC_PROD false
type This will determine what type of build is generated by Xcode.
Valid options are development, enterprise, adhoc, and appstore
CORDOVA_IOS_PACKAGE_TYPE appstore
verbose Pipe out more verbose output to the shell CORDOVA_VERBOSE false
team_id The development team (Team ID) to use for code signing CORDOVA_IOS_TEAM_ID 28323HT
provisioning_profile GUID of the provisioning profile to be used for signing CORDOVA_IOS_PROVISIONING_PROFILE
android_package_type This will determine what type of Android build is generated. Valid options are apk and bundle CORDOVA_ANDROID_PACKAGE_TYPE apk
keystore_path Path to the Keystore for Android CORDOVA_ANDROID_KEYSTORE_PATH
keystore_password Android Keystore password CORDOVA_ANDROID_KEYSTORE_PASSWORD
key_password Android Key password (default is keystore password) CORDOVA_ANDROID_KEY_PASSWORD
keystore_alias Android Keystore alias CORDOVA_ANDROID_KEYSTORE_ALIAS
build_number Sets the build number for iOS and version code for Android CORDOVA_BUILD_NUMBER
browserify Specifies whether to browserify build or not CORDOVA_BROWSERIFY false
cordova_prepare Specifies whether to run ionic cordova prepare before building CORDOVA_PREPARE true
min_sdk_version Overrides the value of minSdkVersion set in AndroidManifest.xml CORDOVA_ANDROID_MIN_SDK_VERSION ''
cordova_no_fetch Specifies whether to run ionic cordova platform add with --nofetch parameter CORDOVA_NO_FETCH false
cordova_no_resources Specifies whether to run ionic cordova platform add with --no-resources parameter CORDOVA_NO_RESOURCES false
build_flag An array of Xcode buildFlag. Will be appended on compile command. CORDOVA_IOS_BUILD_FLAG []
cordova_build_config_file Call ionic cordova compile with --buildConfig=<ConfigFile> to specify build config file path CORDOVA_BUILD_CONFIG_FILE

Run tests for this plugin

To run both the tests, and code style validation, run

rake

To automatically fix many of the styling issues, use

rubocop -a

Issues and Feedback

For any other issues and feedback about this plugin, please submit it to this repository.

Troubleshooting

If you have trouble using plugins, check out the Plugins Troubleshooting doc in the main fastlane repo.

Using fastlane Plugins

For more information about how the fastlane plugin system works, check out the Plugins documentation.

About fastlane

fastlane is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out fastlane.tools.