ionic_integration plugin

fastlane Plugin Badge

Getting Started

NOTE This is hot off the press and I am still testing it locally, so hang tight

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

fastlane add_plugin ionic_integration

About ionic_integration

Integrating Fastlane with Ionic Generated Projects

Fastlane is an awesome application. However the assumption is that you are in control of the iOS or Android projects while using it. When developing in Ionic (or Cordova), the relevant platform projects are created for you by Ionic. For example ionic platform add ios

This poses a problem when attempting to automate the build process. We do not want to put the generated projects under source control, however we would like to be able to link it into fastlane??

This plugin will let you generate a sample UI Test group for generating snapshots the fastlane way. But it stores the UI Unit tests in your fastlane folder so that you can commit only these to version control. The plugin, will then retrofit these tests into the Ionic/Cordova generated projects.

There are two actions (so far) ionic_ios_config_snapshot get's you started with a sample UI Test configuration (and saves it to fastlane/ionic/config/ios/ui-tests). The UI Unit Tests are linked into any existing XCode project generated by Ionic.

ionic_ios_snapshot Scans the fastlane/ionic/config/ios/ui-tests folder for sub folders that represent UI Test Schemes (each folder is a scheme). It retrofits each UI Test scheme into the XCode projects generated by Ionic.

NOTE: At the moment this works for Xcode 8+. If anyone out there is interested in contributing, it would be great to support XCode 7 and (ideally) be able to do a similar thing for Android generated projects.

Example

Check out the example Fastfile to see how to use this plugin. Try it by cloning the repo, running fastlane install_plugins and bundle exec fastlane test.

To create a sample test you can add a lane like so:

lane :setup_tests do
    ionic_ios_config_snapshot(
      ionic_scheme_name: "blah-blah"
    )
end

This will create a folder fastlane/ionic/config/ios/ui-tests/blah-blah

In this folder will be the standard test files that you would expect for a UI Unit Test, Info.plist, Fastlane SWIFT file and a sample Unit Test ui-snapshots.swift

ionic_ios_config_snapshot also executes the ionic_config_snapshot action to retrofit this unit test configuration into any existing XCode Project

When this is done. The sample will be linked into your generated project. In the above example, a UI Test scheme will be created in fastlane/ionic/config/ios/ui-tests/blah-blah. The files in this folder are linked absolutely into Xcode, that is Xcode refers directly to these files (they are not copied over to Xcode)

If you open up Xcode and open the file 'blah-blah/ui-snapshots.swift' you will see something like this:

    func testSnapshots() {

        //
        // Place your own tests here. This is a starter example to get you going..
        //
        snapshot("app-launch")

        // XCUIApplication().buttons["Your Button Name"].tap()

        // snapshot("after-button-pressed")

    }

In the XCode UI, select the scheme 'blah-blah' and click into the method 'testSnapshots()' (after the first snapshot). Then Run the scheme. This will open the simulator and you can click around in your application. XCode will record, each interaction within the testSnapshots() method.

When you are done, you can save everthing and it will save those interactions into the fastlane/ionic/config/ios/ui-tests/ui-snapshots.swift.

You can now add fastlane snapshot("decription") where you like.

This whole operation only needs to be done once (or if you want to add more screenshots later). The UI Test files can be added to your source control and they will be retrofitted into any future generated Ionic projects. Nice.

Your fully automated Fastlane file can now look like this:

platform :ios do

  before_all do
    #
    # This will retrofit any existing schemes in fastlane/ionic/config/ios/ui-tests/
    #
    ionic_ios_snapshot(
        team_id: "[YOUR TEAM ID]"
        bundle_id: "[YOUR APP BUNDLE ID]"
    )
  end

  lane :release do
    # This will run the retrofitted UI Tests for you and create snapshots... :-)
    snapshot(
      output_simulator_logs: true,
      reinstall_app: false,
      erase_simulator: true,
      scheme: "[Name of folder in fastlane/ionic/config/ios/ui-tests/, i.e. blah-blah]"
    )
  end
end

You can now use this to fully automate the build process between ionic and fastlane, including snapshots.

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 guide.

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.