OpenUI5 & Cordova – Setup and first steps
WebStorm is a great IDE and allows to create an empty Cordova project with one click. In the project structure, at least one folder catches someone’s eye: “www”. This is the place to store your SAPUI5 code. I downloaded the OpenUI5 “UI5 Runtime Mobile” pack, extracted it to the www folder (in a subfolder of course) and created a simple index.html file bootstrapping SAPUI5 and added cordova.js to be loaded, too.
When running this setup in your local browser, it will fail to load cordova.js as this file will be added to the output folder (myProject/platforms/android/assets/www” when you build your project using the command “cordova build android”. It is not part of the “myProject/www” folder.
I also added a reference to index.js file, in which I am handling the load events. All further processing (defining the paths, creating the app, etc) should be done whenever the event “onDeviceReady” has been fired to ensure that all libraries have been loaded completely.
Basically, decide upfront whether to use cordova or phoneGap and stick to this decision to avoid ugly side effects.
Cordova apps can be debugged in the desktop browser to some extend (calling the native code of course) but you need to copy the relevant js files (e.g. cordova.js) to the www folder (or create a symlink).