facebook

Migrating a PhoneGap App from MyEclipse 2015 to 2016

Use this guide to migrate your PhoneGap project from MyEclipse 2015 into MyEclipse 2016 and continue development using the PhoneGap CLI.

If you would still like some integrated tool assistance, you can try the Eclipse Thym plugin, though almost all actions can be performed using the CLI—this guide details both options.

For the easiest application build experience, we recommend building your app remotely using the PhoneGap Build service. However, if you are comfortable with local SDK setup, you can choose to build your applications locally and switch to using the Cordova CLI directly instead of the PhoneGap CLI—this guide takes you through the remote build approach.

Prerequisites

  1. Install Node.js for your OS. Download and run the installer from:
    https://nodejs.org/en/download/
  2. Install the latest version of PhoneGap. At the command prompt, type:
    npm install -g phonegap@latest
    Tip: Ensure a successful install of version 6.2 or higher by typing:
    phonegap -version
  3. Install Eclipse Thym into MyEclipse 2016 (Optional):
    Go to Help>Install from Site and use the following site: http://download.eclipse.org/thym/releases/latest/
    Select Group items by category, choose the Eclipse THyM: The Hybrid Mobile category, and click Finish.
    Note: Do not choose the Eclipse THyM: Incubating and Experimental plugins as this will cause the installation to fail.
  4. PhoneGap account
    If you were already doing remote PhoneGap builds, you will already have a PhoneGap build account. If not, create one here: https://build.phonegap.com/plans. A free account allows you to remotely build one app at a time.
    Note: Do not sign up with a github account because that will not work with the phonegap cli
    Set up your PhoneGap account for signing your iOS and / or Android apps (click the link for more information)

Working with your project

Importing the Project

If your PhoneGap project is not already in your workspace, import it using File>Import>General>Existing Project into Workspace and point it to your project folder.

To enable the Eclipse Thym functionality, edit the .project file of the project (you will find it in the project root) and add the following: <nature>org.eclipse.thym.core.HybridAppNature</nature>.


hybridapp
Enabling Eclipse Thym functionality 

In future releases of MyEclipse, we will automate the process of adding Thym support, manual editing of the file will not be required.

Building

We will be building our application remotely, using the PhoneGap CLI.

  1. Bring up the context menu on your project and select Show In>Terminal. A command prompt opens in the Terminal view within MyEclipse. Alternatively, you can go to your project folder using an external command prompt.
  2. Type the following command (based on the type of app you wish to build):
    phonegap remote build android
    or
    phonegap remote build ios 
  3. To install your application on your phone, download it from https://build.phonegap.com/apps.
    Alternatively, you can use the run command instead of the build command, which should give you a QR code that you can use to download the app directly onto your device: phonegap remote run android
  4. To enable or disable debug builds, find your app here: https://build.phonegap.com/apps and go to the Settings page and select or disable the “Enable debugging” button. Your next build will respect the new debug settings.

Adding Plugins

Using Thym
  1. Bring up the context menu on your project and select Install Cordova Plug-in.
  2. Find a plugin in the Cordova registry or specify a Git URL and finish the wizard.
Using the CLI
  1. Add the plugin using the following command, executed from your project’s root folder:
    phonegap plugin add <plugin name>|<git url> --save
  2. For plugins from the Cordova registry at http://cordova.apache.org/plugins/ you can use the plugin name:
    phonegap plugin add cordova-plugin-file --save
  3. Alternatively, add the plugin using a Git URL:
    phonegap plugin add https://github.com/apache/cordova-plugin-camera --save
PhoneGap Build will pick up the plugin either from the registry or Git, depending on how you added it to your project.

Modifying config.xml

Using Thym
  • The config.xml file will open with the Thym config.xml editor by default.
  • Use the Overview tab to enter core application metadata like the Id, Description, Author, etc., or, to add Plugins.
  • Use the Platform Properties tab to specify preferences, parameters and access policies.
  • You can also edit the XML directly in the config.xml tab.

Note: The Thym config.xml editor is a Cordova config.xml editor (not PhoneGap) and therefore the field editors may not display all the settings you have in your current config.xml. However, these settings will still be respected by the PhoneGap build, and new elements added through the editor will be respected as well, due to recent changes in PhoneGap build which work better with the Cordova format.

 

Using MyEclipse XML Editor
  • You can also use the MyEclipse XML editor to directly edit the contents of the config.xml file.

Testing your app

Using Thym
  • From the project’s context menu, choose Run As>Run on Android Device/Emulator for Android or Run As>Run on iOS Simulator for an iOS app on OS X.
  • Please note that these actions will only work if you have the corresponding SDKs locally installed, and the iOS Simulator will only work on OS X.
Using the CLI
  • Use the cordova run command to run your app directly on the device or on an emulator.