Export to PhoneGap* Build and Cordova* CLI

Please see this updated article for the latest information regarding exporting to PhoneGap Build and Cordova CLI > https://software.intel.com/en-us/xdk/article/build-your-intel-xdk-mobile-app-using-phonegap-build-or-cordova-cli <


When your Intel® XDK project is built by the Intel XDK cloud-based build system, it is converted into an Apache* Cordova* CLI project and then built as a standard Cordova CLI application. By way of the Cordova Build Package tile on the Build tab, you can also use Adobe* PhoneGap* Build or Cordova CLI to build your Intel XDK project, instead of the Intel XDK cloud build system.

In the past, if you wanted to build your Intel XDK project using PhoneGap Build or Cordova CLI you had to create a Cordova config.xml file by hand and prepare your source folders for use by those tools. The Intel XDK now includes the ability to generate a Cordova Build Package that you can submit directly to PhoneGap Build, or quickly turn into a buildable Cordova CLI project.

Two methods for accomplishing this are described below. The first utilizes the built-in Cordova Build Package tile on the Build tab and the second uses an external Node.js* script named xdk-to-cli.

After you have successfully exported a Cordova Build Package you can build your app using either PhoneGap Build or Cordova CLI (or compatible build systems). See the doc pages titled Build using PhoneGap Build and Build using Cordova CLI for details.

You should Build using PhoneGap Build if you want the simplest build experience or are not sure. This process does not require installation of any software and performs the build in the cloud, like the Intel XDK build system. It has plugin limitations similar to the Intel XDK build system, specifically, plugins that utilize custom gradle scripts are not supported. This is the best place to start, if it does not serve your needs you can easily change to Cordova CLI.

You should Build using Cordova CLI if you want maximum control and flexibility over your build process. You will also have access to the widest range of Cordova plugins. In this case you must install Node.js, Cordova CLI and the requisite backend build tools (Android Studio, Xcode and Visual Studio) to perform your Cordova builds. Building for iOS requires access to a Mac (and Xcode) and building for Windows requires access to a Microsoft Windows machine (and Visual Studio).

Using the “Cordova Build Package” Export Tool

The process described below will generate a ZIP file that contains a copy of your project’s source and asset files and an auto-generated config.xml file. That config.xml file contains the instructions needed by Adobe PhoneGap Build or Cordova CLI to build your app as a standard mobile app package.

In the text below, PGB is shorthand for PhoneGap Build and CLI is shorthand for Cordova CLI.

The basic process is:

  • Projects tab: select the Intel XDK project to be built with PGB or CLI.
  • Projects tab: insure that all project Build Settings are correctly specified.
  • Build tab: click the Create Package button on the Cordova Build Package tile.
  • Build tab: save the ZIP file that is created to your local hard drive.
  • PGB: submit the ZIP file to PhoneGap Build using your PGB account.
  • CLI: extract the ZIP file and use Cordova CLI to build your app.

Create the Cordova Project ZIP File

Use the Cordova Build Package export tool on the Build tab to create the Cordova project ZIP file that you will submit to PhoneGap Build or use to build locally with Cordova CLI. The project settings in the Build Settings section of the Projects tab must be specified correctly to create the project ZIP file.

A green checkmark icon next to a build target indicates that you can successfully export your project Build Settings (see the middle target in the image below). An orange (!) icon next to a build target means some warnings will be generated during the export, but the export will succeed (see the top target in the image). A red (!) icon next to a specific build target lets you know that there are some Build Settings that require your attention (see the bottom target):

Hover over the red (!) icon for a link that will take you to the Build Settings on the Project tab. Once on the Project tab you may have to expand the Build Settings and select the specific build target tab in the Build Settings section to make the necessary corrections:

Packages exported for use with PhoneGap Build and Cordova CLI will ignore the “certificate fields” in the Build Settings section of the Projects tab. Your build certificates must be added manually to your PhoneGap Build account or your Cordova CLI project. Adding build certificates to your PhoneGap Build account or your Cordova CLI project is an operation that you must perform, the Intel XDK cannot do this for you.

You can disable a build target if you want to limit the build instructions in the config.xml file to specific targets (e.g., only Android* and iOS*). For example, if you have never built for Windows* you likely do not have any meaningful Build Settings configured for that build target, so you can simply “disable” that build target, rather than try to configure Windows for a successful build:

pgb click exclude

Finally, use the Create Package button to create a ZIP file that includes your app sources and a config.xml file for building with either PhoneGap Build or Cordova CLI:

Cordova Build Package ZIP File Contents

The contents of the ZIP file that is generated by the Cordova Build Package export tool are your source and assets folders along with a config.xml file formatted for use with PhoneGap Build or Cordova CLI:

The www folder contains your application source files and is an identical copy of the www folder in your Intel XDK project folder. Likewise, the package-assets folder is an identical copy of the same-named folder in your Intel XDK project folder; it contains your app icons and splash screen images.

The config.xml file is a merge of your project’s Build Settings from the Projects tab and the intelxdk.config.additions.xml file (if any) located in the root of your Intel XDK project folder (similar to the various intelxdk.config.<target-platform>.xml files that are auto-generated).

Other folders and files may be present in the ZIP file, but they will be ignored by PhoneGap Build and Cordova CLI. Usually, any extra files and folders are just informational elements that were part of a sample or template project that was used to create your project.

If you are familiar with Cordova CLI projects, you will notice there are no plugins, platforms or hooks folders in the root of the exported project. This is by design; those folders are ignored by PhoneGap Build and will be auto-generated by Cordova CLI.

After you have successfully exported a Cordova Build Package you can build your app using either PhoneGap Build or Cordova CLI (or compatible build systems). See the doc pages titled Build using PhoneGap Build and Build using Cordova CLI for details.

Using the ‘xdk-to-cli’ Node.js Script

If you are unable to successfully create a ZIP file using the Cordova Build Package tile, or you want more control over that process, you may need to use this xdk-to-cli Node.js script. Full instructions and requirements are provided in the script’s README file.

Using xdk-to-cli with PhoneGap Build

This script does not create a ZIP file, it only creates three target- specific build configuration files. The config files it creates are written to the root folder of your Intel XDK project.

To create a ZIP file for submission to PhoneGap Build:

  • Create a config.xml file from the relevant config.*.xml files (per the instructions in the script’s README) and save it to the root of your Intel XDK project folder.
  • ZIP the contents of the entire Intel XDK project folder and submit it to PhoneGap Build (PhoneGap Build will ignore the plugins folder in the ZIP file).

If the resulting ZIP file is too large for submission to PhoneGap Build, you can exclude the plugins folder (and any other extraneous folders and files) from the ZIP, to save space. The plugins folder is not needed because PhoneGap Build uses the <plugin> tags in your config.xml file to retrieve the plugins required by your application.

 Using xdk-to-cli with Cordova CLI

If you are going to use Cordova CLI to build your project, you will need to make a copy of the Intel XDK project folder (excluding the plugins folder) and then execute the necessary cordova commands to create a buildable Cordova CLI project. In general, it is not a good idea to use the existing plugins folder that is already present in the Intel XDK project because the Intel XDK internal plugin add mechanism that creates that plugins folder short circuits the normal Cordova plugin add operations, in order to provide support for all build platforms, regardless of your development OS. This short circuit mechanism can interfere with a local Cordova CLI build.

For more details on how to continue to use the Intel XDK alongside a Cordova CLI build system, see the section titled Integrating Cordova CLI with the Intel XDK in the Build Using Cordova CLI doc page.

For more complete information about compiler optimizations, see our Optimization Notice.