Build Hybrid Sample Apps
To build hybrid apps from the samples directory of the SalesforceMobileSDK-Shared repository, you use forcehybrid and the Cordova command line. You create a hybrid_local or hybrid_remote app and then add the web assets—HTML, JavaScript, and CSS files—and the bootconfig.json file from the Shared repo.
The ContactExplorer sample requires the cordova-plugin-contacts and cordova-plugin-statusbar plug-ins.
The other hybrid sample apps do not require special Cordova plug-ins.
To build one of the sample apps:
-
Open a command prompt or terminal window.
-
Clone the shared repo:
1git clone https://github.com/forcedotcom/SalesforceMobileSDK-Shared
-
Use forcehybrid to create an app.
- For platform, enter one or both platform names: “ios”, “android”, or “ios,android”.
- For application type (or the
apptype parameter), enter “hybrid_local”.
-
Change to your new app directory:
1cd <APP_TARGET_DIRECTORY>
-
For each additional Cordova plug-in you want to add, type:
1cordova plugin add <PLUG-IN REPO OR PLUG-IN NAME>
Go to https://plugins.cordova.io to search for available plug-ins.
-
(Optional—Mac only) To add iOS support to an Android project “after the fact”:
1cordova platform add ios@
-
(Optional—Mac only) To add Android support to an iOS project “after the fact”:
1cordova platform add android@
-
Copy the sample source files to the www folder of your new project directory.
On Mac:
1cp -RL <LOCAL PATH TO SALESFORCEMOBILESDK-SHARED>/SampleApps/<TEMPLATE>/* www/
On Windows:
1copy <LOCAL PATH TO SALESFORCEMOBILESDK-SHARED>\SampleApps\<TEMPLATE>\*.* www
If you’re asked, affirm that you want to overwrite existing files.
-
Do the final Cordova preparation:
- Android Studio refers to forcehybrid projects by the platform name (“android”). For example, to run your project, select “android” as the startup project and then click Run.
- On Windows, Android Studio sets the default project encoding to
windows-1252. This setting conflicts with the UTF-8 encoding of the forcehybrid Gradle build files. For best results, change the default project encoding to UTF-8.
- On Windows, be sure to run Android Studio as administrator.
Welcome to the new home of the Mobile SDK Developer Guide! For now, the Japanese guide can be found in PDF form.