Creating an Apache Cordova Project
To create an Apache Cordova project for use with the Hybrid SDK (Kapsel), use the Cordova command line tool.
You must run the commands from a Windows command prompt, or a terminal window on iOS. See http://cordova.apache.org/docs/en/6.x/guide/cli/index.html.
- (Optional) Create a folder to hold your Hybrid SDK (Kapsel) Cordova projects.For example, on Windows, C:\Documents and Settings\<your_account>\Kapsel_Projects, or on OS X, ~/Documents/Kapsel_Projects.
- (Optional) Open a Windows command prompt or terminal and navigate into the project folder you created.
- At the command prompt, enter:
cordova create <Project_Folder> <Application_ID> <Application Name>
Use the appropriate delimiter for path names.
This command may take a few minutes to complete, as an initial download of the template project that is used is downloaded to C:\Users\user\.cordova on Windows, or ~/users/user/.cordova on Mac.
The parameters are:
- (Required) <Project_Folder> – the directory to generate for the project.
- (Optional) <Application_ID> – must match the Application ID as configured on SAP Mobile Platform Server for the application, which is reverse-domain style, for example, com.sap.kapsel.
- (Optional) <Application_Name> – name for the application.
In this example, you create a project folder named LogonDemo in the Kapsel_Projects directory. The Application ID is "com.mycompany.logon" and the application name is "LogonDemo." Running cordova -d allows you to see the progress of the project creation.
cordova create ~\Kapsel_Projects\LogonDemo com.mycompany.logon LogonDemo
Your new project includes scripts to build, emulate, and deploy your application.
- To add the platform, change to the folder you created in the previous step: cd <~Project_Name>This OS X example adds the Android , iOS, and Windows platforms.
cd ~\Kapsel_Projects\LogonDemo cordova platform add ios android windowsThe project directory structure is similar to this:
LogonDemo/ |--.cordova/ |-- merges/ | |-- android/ | `-- ios/ |-- platforms/ | |-- android/ | `-- ios/ |-- plugins/ |-- www/ -- config.xml `
- .cordova – identifies the project as a Cordova project. The command line interface uses this folder for storing its lazy loaded files. The folder is located immediately under your user’s home folder (On Windows, c:\users\user_name\ , and on Macintosh, /users/user_name/.cordova).
- config.xml – the config.xml file in the root directory contains meta data and native application information needed to generate the application.
- platforms – native application project structures are contained in subfolders for the platforms you added to your application.
- (Optional) You can test your Cordova project by opening it in the respective development environment, for example, Xcode or Android Studio, and running it on the simulator or emulator. If you are going to import your project into Android Studio, you must run cordova build android.
- Add the plugins. See the detailed instructions for adding each plugin in Hybrid SDK
(Kapsel) Plugins. For example, to add the Cordova console plugin and the
Hybrid SDK (Kapsel) Logon plugin on Windows, enter:
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git cordova plugin add C:\SAP\MobileSDK3\KapselSDK\plugins\logon
- Edit the Web application content in the project's www folder and use the
cordova prepare command to copy that content into the Android,
iOS, and Windows project folders:
cordova prepare android cordova prepare ios cordova prepare windows