Creating a Cordova project with the CLI

Create a Cordova project by using the mfp cordova create command, then configure and preview your app.

Before you begin

Before you can create a Cordova project, you must create an application back-end runtime. For more information, see Creating an app back-end runtime.
Note: The Keychain Sharing capability is mandatory while running iOS apps in the iOS Simulator when using Xcode 8. You need to enable this capability manually before building the Xcode project.

Procedure

  1. Create a Cordova project. Run
    mfp cordova create myCordovaProject

    where myCordovaProject is the name of your Cordova project. For more information, see cordova create.

    Important: If you are creating an app for the Android platform, make sure that you set your ANDROID_HOME environment variable to your Android SDK.
  2. Run cd myCordovaProject to change into your Cordova app project directory.
  3. Optional: Run mfp config to configure the application settings. For more information, see config.
  4. Develop the app in your preferred integrated development environment (IDE) or source code editor.
  5. Update the necessary files of your project by using the mfp cordova prepare command. For more information, see cordova prepare.
  6. For Android platform only: If you require the Cordova camera plug-in, you must complete the steps in Preparing a project that uses the Cordova camera plug-in with the Android platform.
  7. Push the app to your server by using the mfp push command.
    • For a local development server, run mfp push local.
    • For a remote server, run mfp push RemoteServerDefinition, where RemoteServerDefinition is the name of the server definition that was given to the server when it was created.
    For more information, see push.
  8. Test your application by either previewing it in a browser, running it on a device emulator, or running it on a device.
    • To preview your app in a browser, run mfp cordova preview. For more information, see cordova preview.
    • To run your app on a device emulator, run mfp cordova emulate. For more information, see cordova emulate.
    • To run your app on a device, run mfp cordova run. For more information, see cordova run.
    (Android and iOS development only.) If you are developing your app for the Android or iOS platforms or adding the Android or iOS platform to an existing app, the following files are replaced by a version of the file that is provided by IBM MobileFirst Platform Foundation when you add the platform to your app that contains the cordova-plugin-mfp plug-in. These files are:
    • Android: The file MainActivity.java is replaced. Your original MainActivity.java file is backed up and renamed MainActivity.original.
    • iOS: File main.m is replaced. Your original main.m file is backed up and renamed main.m.bak.
    If you made any changes to the original versions of these files, you must merge the changes that you made into the new version of the file that is provided by IBM MobileFirst Platform Foundation.